Reputation: 1
[Passing an object from JSP page back to Servlet
From the top reviewed answer of the question above, What does Form preprocessing Servlet and Form postprocessing Servlet mean? Where do I put it in my servlet? Do I put it on the same method? Do I call preprocessing Servlet first then proceed with the form submission of my JSP file and then proceed to the postprocessing file?
Upvotes: 0
Views: 128
Reputation: 79395
You write both the code in the same servlet in the sequence mentioned below:
A. Get the request parameters from the request (which may have values of HTML form elements and explicit request parameters), as mentioned in the Form postprocessing part
String myObjectId = request.getParameter("myObjectId");
Object myObject = request.getSession().getAttribute(myObjectId);
request.getSession().removeAttribute(myObjectId);
// ...
B. Perform some business logic and forward the request to some JSP, as mentioned in the Form preprocessing part
String myObjectId = UUID.randomUUID().toString();
request.getSession().setAttribute(myObjectId, myObject);
request.setAttribute("myObjectId", myObjectId);
request.getRequestDispatcher("/WEB-INF/page.jsp").forward(request, response);
Upvotes: 1