OneCompiler

Jsp page bro

178

<%@page import="java.util.List"%>
<%@page import="model.Customer"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>All Customers</title> <link rel="stylesheet" href="../static/css/styles.css"> </head> <body> <header> <h1>All Customers</h1> </header> <main> <section> <h2>Customer List</h2>
        <sql:setDataSource var="db" driver="org.sqlite.JDBC" url="jdbc:sqlite:banking_management_system.db" />
        <sql:query dataSource="${db}" var="customers">
            SELECT * FROM customer;
        </sql:query>

        <table border="1">
            <thead>
                <tr>
                    <th>Account Number</th>
                    <th>Name</th>
                    <th>Gender</th>
                    <th>Account Type</th>
                    <th>Balance</th>
                    <th>Actions</th>
                </tr>
            </thead>
            <tbody>
                <c:choose>
                    <c:when test="${not empty customers.rows}">
                        <c:forEach var="customer" items="${customers.rows}">
                            <tr>
                                <td>${customer.accountNumber}</td>
                                <td>${customer.accountHolderName}</td>
                                <td>${customer.gender}</td>
                                <td>${customer.accountType}</td>
                                <td>${customer.balance}</td>
                                <td>
                                    <form action="../DeleteCustomerServlet" method="post" style="display:inline;">
                                        <input type="hidden" name="accountNumber" value="${customer.accountNumber}">
                                        <button type="submit">Delete</button>
                                    </form>
                                    <a href="update.html?accountNumber=${customer.accountNumber}">
                                        <button>Update</button>
                                    </a>
                                </td>
                            </tr>
                        </c:forEach>
                    </c:when>
                    <c:otherwise>
                        <tr>
                            <td colspan="6">No customers available</td>
                        </tr>
                    </c:otherwise>
                </c:choose>
            </tbody>
        </table>
    </section>
</main>
<footer>
    <p>© 2024 Banking System</p>
</footer>
</body> </html>