On Friday 10 January 2003 02:14 pm, Erik Price wrote:
> Hi,
>
> Sorry if this is too simple a question, I'm still just getting my first
> JSP/servlet application underway.
>
> I have a servlet called LoginServlet, that is passed some POST
> parameters and does some processing with them.  There are two possible
> outcomes -- one is that the authentication fails and the user is sent to
> a page indicating that they failed to log in.
>
> The other outcome is that the user is taken to "main.jsp", which is a
> JSP that I have written which serves as a kind of welcome page for
> logged-in users.
>
> The technique that I would use to do this redirection is to call
> getRequestDispatcher() from the servlet context and employ the forward()
> method of the RequestDispatcher object.  The problem is that doing so
> preserves the original URL of LoginServlet.
>
> My question is: how can I send the user to "main.jsp" without using
> dispatcher.forward(), so that the URL is appropriately displayed as
> "main.jsp" (plus any other URL parameters such as URL-encoded session
> data, etc)?
>
> I would like to do this without using filters since I haven't learned
> how to use these yet.
>
> Thank you,
>
>
> Erik

Hi Erik,

sendRedirect() in HttpServletResponse will send an HTTP redirect response to 
the client so the client's browser itself makes a new request to the new URL 
(main.jsp in your case). It results in the new URL being shown in the 
browser's address field.

Note that the original request's parameters, which were sent to the servlet, 
are lost but check the sendRedirect()'s documentation for more details.

Paul

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to