I have 5 jsp pages with forms on each page. When I click on the submit button on each page the form is submitted to a servlet(Reg) and the values are stored in a class (bean). I use requestdispatcher to get the textfields from step1 in step2 and likewise step2 values in step3 and so on.
Now I want the values of the textfields dob and regDate (which are in my step1.jsp) in step4.jsp. How do I do that? Below is an example of the code I've written.
step1.jsp
<div>
<form name="step1">
<input type="text" name="dob" id="dob">
<input type="text" name="regDate" id="regDate">
<input type="submit" name="step1nxt" value="submit">
</form>
</div>
Step4.jsp
<div>
<form name="step4">
<input type="text" name="dod" id="dod">
<input type="submit" name="step4nxt" value="submit">
</form>
</div>
Reg.java ( Servlet )
if(step1nxt!=null){
//call function to set values in bean
request.getRequestDispatcher("step2.jsp").forward(request,response);
}
if(step2next!=null){
//call function to set values
request.getRequestDispatcher("step3.jsp").forward(request,response);
}
//similar 'if' statement for other pages
if(step4.nxt!=null){
//call function to set values
request.getRequestDispatcher("step5.jsp").forward(request,response);
}
bean.java
String dob;
String regDate;
//getters and setters
//function to setvalues of dob and regDate
//function to print the values