I have some standard code for forwarding to a JSP from within a servlet:
That method is called like this:
I have that #shortcut on the end of the path because in the HTML on that page I have an anchor like this:
Nothing strange--I just want the browser the browser to scroll down the page to that point so the user doesn't have to keep on doing that. I can easily do this with a couple of barebones HTML pages, but I'm guessing the servlet or RequestDispatcher doesn't like that pound sign, because whenever it tries to forward there I just get an HTTP 404 error ("The page cannot be found");
Is there any way I can get around this, or is there a way to get the browser to jump to that spot based on something in the HTML (something I can dynamically stick into onLoad, perhaps?). Thanks...
'forward' happens on the server and indicates that another resource will fill the request.
'#' happens in the client (in the browser) and jumps to a tag in the page.
The two aren't compatible. You may find that sendRedirect is what you are looking for. It sends a message to the client asking them to request the resource indicated, and should support the 'hash' too.
Joined: Jul 15, 2003
Yeah, sendRedirect works, but then I lose my original request parameters. That's why I wanted to use forward. No chance there's a way to make the Java code in the JSP spit out some HTML that will cause the browser to skip down to the name when the page is loaded...?