• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to transfer object from servlet tp JSP and back to Servlet

 
mvPrasad Regula
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an issue:
I jave two jsp's jspone and jsptwo and two servlets Servone and Servtwo.
Steps I am supposed to do:
1. Enter data in jspone
2. Click on Submit to ServletOne(using <Form> tag)
3. Collect the values in servlet one and set the values to ValueObjectOne.
4. Set CaluObjectOne to request object.
5. Using RequestDispatcher(request.getRequestDispatcher()) forward to jsptwo.
6. Declare <%@Usebean ...%> in jsptwo
7. Enter the values in jsptwo and submit the form
8. Use ServletTwo and collect ValueObjectOne and ValueObjectTwo(Generated from jsptwo) --> //Here I am failing. I am getting both the
//valueObjects as null
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34214
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless the object is in the HttpSession, it is gone once the request is done. This would we when the JSP finishes rendering. If you don't want to use the session, you can pass the fields in the object via a forum and create a new object.
 
mvPrasad Regula
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried session earlier. If I type session, I am getting error there.
I will paste my code below could you please make the changes. I will be thankful to you.
1. jspone


2. JSPTwo


3. ServletOne



4. ServletTwo
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic