0

I have created a maven project which runs fine. My project run successfully and all fields are correctly updated to database once I run. But I want to display those fields in my project, so I created one jsp file called history.jsp. I used JSTL here to display my fields. But once I click the button "Transaction history" (which is linked to my history.jsp file) I receive error "HTTP Status 500 – Internal Server Error". I have added the "jstl-1.2" maven dependency to my pom.xml file.

Here is code of my profile.jsp file :

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    
<%@ taglib prefix = "c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix = "sql" uri="http://java.sun.com/jsp/jstl/sql" %>

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Transaction History</title>
</head>
<body style="background-image: url('https://media.istockphoto.com/vectors/empty-blank-pastel-faded-pale-very-light-sky-blue-and-white-coloured-vector-id1355217474?b=1&k=20&m=1355217474&s=170667a&w=0&h=iFvjFzoWYJSEL36G41H0uPJbxOQfJJC6_LmMYiM5wVs='); background-size: 100%;">
    <div style="padding: 80px;">
    <h1 style="color:blue;">Transaction History</h1>
    <sql:setDataSource var="table" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/transaction" user="root" password="root" />
    <sql:query var="rs" dataSource="${table}"> select * from deposite_withdraw where user_email = "${ user.getEmail()}"</sql:query>
    <table class="table table-striped">
  <thead>
    <tr>
      <th scope="col">Date</th>
      <th scope="col">Amount</th>
    </tr>
  </thead>
  <tbody>
    <c:forEach items="${rs.rows }" var="trs">
        <tr> 
        <td> <c:out value="${trs.transaction_date}" /> </td>
        <td> <c:out value="${trs.amount }" /> </td>
        </tr>
    </c:forEach>
  </tbody>
</table>
</div>
</body>
</html>

Here is my dashboard.jsp file from where I'm calling this history.jsp

<%@page import="java.util.jar.Attributes.Name"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
        integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">

    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css"
        integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">

<title>Insert title here</title>
</head>
<body>

     <% 
     
     response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
     
     if(session.getAttribute("user")==null){
         response.sendRedirect("login.jsp");
     }
         
    %>

    <nav class="navbar navbar-expand-sm navbar-dark bg-dark">
        <div class="container">

            <div class="collapse navbar-collapse" id="mobile-nav">
                <ul class="navbar-nav mr-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="dashboard.jsp">
                            Dashboard
                        </a>
                    </li>
                </ul>
                
                <form action="/logout">

                <ul class="navbar-nav ml-auto">
                   
                    <li class="nav-item">
                        <a class="nav-link" href="login.jsp">
                            Logout
                        </a>
                    </li>
                </ul>
                
                </form>
            </div>
        </div>
    </nav>
    

    <div class="projects">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <h1 class="display-4 text-center">Personal Bank</h1>
                    
                    <div class="card text-center">
                        <div class="card-header bg-warning text-white">
                            <h4>Welcome to your personal bank</h4>
                            <h1>Sarwvidya</h1>
                        </div>
                    </div>
                    

                    <!-- Project Item Component -->
                    <div class="container">
                        <div class="card card-body bg-light mb-3">
                            <div class="row">
                                
                                <div class="col-lg-4 col-md-3 col-6 text-center">
                                    <h3>Current Balance</h3>
                                    <h1>Rs. 27000</h1>
                                </div>
                                <div class="col-md-4 col-12 d-lg-block">
                                    <ul class="list-group">
                                        <a href="credit.jsp">
                                            <li class="list-group-item board text-success">
                                                <i class="fa fa-flag-checkered pr-1"> Credit </i>
                                            </li>
                                        </a>
                                        <a href="debit.jsp">
                                            <li class="list-group-item update text-info">
                                                <i class="fa fa-edit pr-1"> Debit </i>
                                            </li>
                                        </a>
                                        
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div>
                    <button class="btn btn-info"><a href="history.jsp" style="color:white ;"> Transaction History </a></button>
                    </div>
                    <!-- End of Project Item Component -->

                </div>
            </div>
        </div>
    </div>
    
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
        integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
        crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
        integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
        crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"
        integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T"
        crossorigin="anonymous"></script>

</body>
</html>

My database name : transaction

Table name: deposite_withdraw

Fields : user_email (varchar), amount (varchar), date (varchar)

I'm getting this error. Pls help me to resolve this.enter image description here

Sarwvidya
  • 13
  • 4
  • 1
    FYI: please catch up your learning resources and make sure that they are not written by amateurs with the sole purpose to earn advertising incomes by copy pasting dubious code snippets. Using `` tags and using `<% scriptlets %>` is namely officially discouraged since introduction of JSP version 2.0 in 2003 and considered a bad practice since. That's **twenty** years ago already! – BalusC Feb 22 '23 at 14:38

0 Answers0