Skip to Main Content

How to carry an object from one JSP to another JSP?

srhcanMay 4 2012 — edited May 29 2012
How can I carry an object from one JSP to another JSP?

I have a servlet where I am setting an object in request as an attribute and then forwarding to PageA.jsp.
MyDTO myDTO = new MyDTO();
request.setAttribute("MyDTO", myDTO);
RequestDispatcher rd = getServletContext().getRequestDispatcher("/PageA.jsp");
rd.forward(request, response);

I can get MyDTO object in PageA.jsp:
MyDTO myDTO = (MyDTO) request.getAttribute("MyDTO");

Now PageA.jsp has a form named form_pageA which submits to PageB.jsp. How can I make sure that myDTO object is available in PageB.jsp? I would like to not store it in session.

Edited by: srhcan on May 4, 2012 7:52 PM
Post Details
Added on May 4 2012