0

I am trying to forward a list to print in a .jsp page But I am unable to get a proper output.

From Servlet

    request.setAttribute("bankStatements", transactionDetailsBeanList); 
    RequestDispatcher rd = getServletContext().getRequestDispatcher("/displayBankStatement.jsp");
    rd.forward(request, response);

.jsp file

   <c:forEach items="${bankStatements}" var ="bankStatement" >

   <tr><td>${bankStatement.transactionId}</tr></td>

  </c:forEach>

Faulty values displayed

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Are you specifying that c is jstl core at the top of your JSP file? Just a thought, my JSP skills are very rusty! – Chris Jun 02 '20 at 20:22
  • Are you trying to access the JSP directly? It's difficult to say anything without looking into your code. Follow [this working example](https://stackoverflow.com/questions/62118682/displaying-map-in-tabular-format-which-has-object-as-key-and-arraylist-as-value/62119633#62119633). – Arvind Kumar Avinash Jun 02 '20 at 20:23
  • I.e. <%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %> – Chris Jun 02 '20 at 20:24
  • @Chris It is present check the file here https://github.com/DipanjanSG/BankingApp/blob/master/src/main/webapp/displayBankStatement.jsp – Dipanjan Sengupta Jun 03 '20 at 06:17
  • @ArvindKumarAvinash Check this link..... jsp file-https://github.com/DipanjanSG/BankingApp/blob/master/src/main/webapp/displayBankStatement.jsp the jsp file is being called from here (Check line 69) - https://github.com/DipanjanSG/BankingApp/blob/master/src/main/java/BusinessLogic/DisplayBankStatement.java – Dipanjan Sengupta Jun 03 '20 at 06:18
  • @ArvindKumarAvinash I am sure that the transactionDetailsBeanList in line 68 is not empty – Dipanjan Sengupta Jun 03 '20 at 06:37
  • Ah okay, it was just a bit of a guess on my part. Looks like someone has pointed you to a previous SO answer so hope that fixes it for you – Chris Jun 03 '20 at 09:41
  • @Chris I tried following the instructions in the second comment . I am unable to resolve the issue. Pls help – Dipanjan Sengupta Jun 04 '20 at 08:53
  • Ah, I'm pretty rusty as mentioned, I haven't worked with JSP for about 3 years. I'll have a quick look at your code when I get a chance to see if I can spot anything obvious, but don't be too optimistic! – Chris Jun 04 '20 at 11:51
  • Have you seen this question/answer https://stackoverflow.com/a/25372735/2568649 I notice your web.xml uses the same docttype declaration. Maybe worth trying this other version. Also note the point about JSP caching, if you change web.xml do edit the JSP in some arbitrary way, else it won't get recompiled – Chris Jun 04 '20 at 21:15

0 Answers0