Friends,
I've been doing a lot of reading about the MVC design
pattern (how it pertains to
Servlets and JavaServer Pages) as well as the double post problem and the Post-Redirect-Get design pattern to work around it.
I really like the way I can
forward from the Servlet (controller) to the
JSP (View) and it maintains the original URL. Also, this makes it possible to forward to a JSP page which is in the WEB-INF directory, essentially hiding it from the world.
However, it seems I can't hide the JSP page in this way when using the PRG design pattern, as I need to redirect to a publicly-visible JSP page.
I would like to be able to use the PRG design pattern (to avoid the double-post issue), but keep the visible URL unchanged. I was thinking I could do the following:
Have the servlet implement different doGet and doPost methods:
- doGet would create the session Bean (if not already created), then forward to the View JSP located in the WEB-INF directory;
- doPost would accept the request from the JSP page, process the request parameters, execute the business logic, then, if it wants to go back to the same JSP page, do a redirect to our servlet - which will end up executing the doGet method, starting the process all over again.
Is there an easier way to do this, or is my solution reasonable?
Thanks,