Having a little trouble deciding the best way around this issue I'm having with page navigation through Servlets...
To try to hide the URLs (path to the JSPs) for each part of my system I have decided to make all page navigation a Servlet call (PageLoader - Servlet), this gets an initParam from the web.xml with the JSP location and passes it into a RequestDispatcher.forward.
Now, everything is fine for the most part... Except! Because requestDispatcher is a server side call, as you know if you refresh (F5) your browser window, the App will 'run' the Servlet again.
this causes a big issue if you are coming from say a CreateUserAccountServet, because when the user account is created and the .forward sends you to your /myaccount page, you hit refresh (F5) and the App will run the CreateUserAccountServlet again and try to create another new account!!! PROBLEM
So I decided to move to .sendRedirect. This is fine expect, because this is a browser call, it replaces the /myaccount (Servlet URL) with the full JSP path from the web.xml (eg: /secure/pages/account/index/myaccount.jsp) this is not what I want.
Is there a way of either stopping RequestDispatcher from re-running the Servlet when you refresh the page or is there a way of hiding the JSP url when using .sendRedirect?
One downside to this approach is, older browsers might not support it.
Originally posted by Srikanth Reddy Lankireddy: If you don't want to show actual path to the user, you can map JSPs in web.xml same as you do with servlets.
The original poster's question had more to do with preventing double submission of forms when page is reloaded or backed into. Mapping JSPs will allow you to change the URLs for them but will do nothing to prevent this issue.
subject: sendRedirect or RequestDispatcher forward - error