It might be irrelevent - but dont forget the redirect happens at the client. So in effect it becomes a new request and you therefore lose any data you might have put in the request scope during your original post.
>From: Zerbe John W <[EMAIL PROTECTED]>
>Reply-To: "A mailing list for discussion about Sun Microsystem's Java Servlet API Technology." <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: Redirect question
>Date: Tue, 4 Feb 2003 10:30:50 -0500
>
>A requestDispatcher.forward() doesn't do a "redirect" via the browser. It only forwards the request to your target jsp within the scope of the servlet request. from the browser's perspective, it looks like the servlet generated the output that really came from your jsp.
>
>Instead of forward(), I believe that you want to do a response.sendRedirect(NEXT_PAGE);
>This will cause an http redirect request to go back to the browser the contents of NEXT_PAGE as the target.
>If you take this approach, if you were setting any attributes on the request object prior to doing your forward(), those attributes would now have to be set in the session prior to the redirect and retrieved from the session via the jsp.
>
>This approach has the advantage that if the browser "refreshes" only the jsp will get run again, not the servlet. Since it sounds like you are following an MVC archetecture, your jsp will be only generating a response and not modifying any data on the server. ;-)
>
>-----Original Message-----
>From: Mike Silvers [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, February 04, 2003 6:46 AM
>To: [EMAIL PROTECTED]
>Subject: Redirect question
>
>
>Hopefully this is something simple :)
>
>I have a jsp that uses a controller servlet to do the processing. From the servlet, the response is redirected according to the processing option. After the redirect, the URL displayed on the browser remains as the servlet URL. I need to have this changed to the proper page URL.
>
>I am doing a redirect -- the code involved in the redirect is as follows:
>
>(getServletContext().getRequestDispatcher(NEXT_PAGE)).forward(request, response);
>
>Before doing the redirect, I set some header values as follows:
>
>response.setHeader("Location", response.encodeURL(NEXT_PAGE));
>response.setHeader("Content-Location", response.encodeRedirectURL(NEXT_PAGE));
>
>Thanks!
>
>Mike
>
>=======================================
>Mike Silvers
>Senior Programmer/Analyst
>IBM Certified Expert
>Hainey Business Systems
>Main Office: (717) 718-9601 ext 237
>Branch Office: (410) 397-8739
>http://www.hbs-inc.com
>=======================================
>
>
>
>DISCLAIMER:
>The information contained in this e-mail may be confidential and is intended solely for the use of the named addressee. Access, copying or re-use of the e-mail or any information contained therein by any other person is not authorized. If you are not the intended recipient please notify us immediately by returning the e-mail to the originator.
Send music and picture to your friends with MSN Messenger.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html