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. ;-)
DISCLAIMER: |
- Redirect Question Milan Tucakovic
- Re: Redirect Question Jozef Chocholacek
- Re: Redirect Question Isaac Shabtay
- Re: Redirect Question Marcus Nordlund (QRA)
- Redirect question Matthias Hanel
- Redirect question Mike Silvers
- Re: Redirect question Zerbe John W
- Re: Redirect question Gareth Jones