after the form is submitted form the page1.jsp it comes to page2.jsp here after the page2.jsp is realised if we refresh the page the request parameter will be null and the page has to be redirected to the page1.jsp this scriplet is present in the page2.jsp this solution is not working .the functionality that i want is after coming to page2.jsp if we refresh the page it should be redirected to the page1.jsp
Instead of transfering the control from the first jsp directly to second jsp use a controller servlet.
Code for first Jsp (JspOne.jsp)
Code for controller servlet
code for second jsp (JspTwo.jsp)
With this logic when you submit your first jsp page the control with go to controller servlet and from there will be redirected to second jsp page. Now you are in your second jsp page. When you make a refresh the control will go back to your first jsp page.
I had executed the code and everything is working perfectly for me. All the best. [ December 07, 2005: Message edited by: Vishnu Prakash ]
you can give the response.sendRedirect() method outside the IF condition, so eventhough the page is refreshed it will be redirected to the page1.jsp
Think about this use case What happens when the user enters for the first time?
When he presses the submit button he will be immediately taken back to the first page without displaying the second page. But the problem demands in the other way. Only when the second page is refreshed user should be taken back to first page.