John McDonald wrote:
> All,I have a question about what the best way to redirect a user may
> be. I have an extensive web app that is presently based on servlets.
> I'm "porting" this web app to JSP, and I'm going to use my servlet to
> authenticate and "direct" the user. Once a user connects to the
> servlet, authenticates, and I have their informaiton, what is the
> best way to send the user to the JSP page. Should I use redirect, or
> is there a better way? Any comments would be appreciated. John D.
> McDonald
Using a redirect would work, but that requires an extra round trip to
the client's browser. For a one-time occurrence, this is no big deal,
but would cause performance issues if you did it on every request.
The RequestDispatcher.forward() call (added in the servlet API version
2.1) was designed for just this sort of purpose. In fact, I use it for
all of my JSP-based apps like this:
* JSP page has an input form to collect user data
* The form is submitted to a servlet
* The servlet performs whatever processing logic
needed to satisfy the request, stores any results
to be displayed in beans, and forwards control
to a JSP page to show the results.
This approach lets me use the MVC architecture approach (beans=Model,
JSP pages=View, servlet=Controller) and separate my business logic from
my presentation logic.
Craig McClanahan
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html