0

So I know there are plenty of answers already on this subject as I have found but no matter what I try I can not get it to work.

JSP:

<%
   SQL data = new SQL();

    ArrayList<Transaction> list = data.getTransactions();
%>

   <table border="0">
        <tr>
            <td class="display_Headers">ID</td>
            <td class="display_Headers">Date</td>
            <td class="display_Headers">To</td> 
            <td class="display_Headers">From</td>
            <td class="display_Headers">Amount</td>
            <td class="display_Headers">Notes</td>
        </tr>
        <%for(int i=0;i<list.size();i++){%>
        <tr class="displayData">
            <td><%=list.get(i).getID()%></td>
            <td><%=list.get(i).getDate()%></td>
            <td><%=list.get(i).getToAccount()%></td>
            <td class="space"><%=list.get(i).getFromAccount()%></td>
            <td class="space"><%=list.get(i).getAmount()%></td>
            <td><%=list.get(i).getNotes()%></td>
        </tr>
        <% } %>
    </table>

I want to build the correct MVC architecture of course. But for now I had to build it this way with the java code in the JSP just to get it to work. The java logic should be in the servlet and there set the data in the request or session attribute to later get it within the JSP page.

The servlet:

HttpSession session = request.getSession();
session.setAttribute("data", nameOfObject);
  request.getServletContext().getRequestDispatcher("display.jsp").forward(request, response);   

I can not seem to get this to work no matter what. Thank you for all of your help.

1 Answers1

0

Why do you get the attribute data? The following line is needed in display.jsp at least.

Object nameOfObject = session.getAttribute("data");
Kohei TAMURA
  • 4,970
  • 7
  • 25
  • 49