jeudi 26 novembre 2020

Transferring data from one JSP to another JSP file using request

I am creating a bookstore application and was working on the checkout functionality. I ran into an issue where I am using this code to attempt to send data from shoppingCart.jsp to checkout.jsp.

ShoppingCart.jsp code:
request.setAttribute("bookData", bookList);
        request.setAttribute("insert","insert");

I am using this in checkout.jsp

        <%ArrayList<Book> bookstore = (ArrayList<Book>)request.getAttribute("bookData");
        String insert=(String)request.getAttribute("insert");

            %>
        <p> You Purchased the following books: </p>
        <h1><%=insert%></h1>

However, all I am receiving is Null value as such. enter image description here

Is there an issue with what I am doing? I could not find what I am doing wrong even after searching online. Any help would be appreciated.

NOTE: I want to pass data from a JSP to a JSP and not a servlet to a JSP.




Aucun commentaire:

Enregistrer un commentaire