You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Cindy Ballreich <ci...@ballreich.net> on 2002/09/26 01:46:16 UTC
forwarding to a page anchor
I'd like to forward to an anchor <a name="anchorName"> in a jsp page, but I keep getting a 404 error when I try to do it. It works from the browser, but not from the server. Is it possible to forward to a page anchor like this?
RequestDispatcher rd =
request.getRequestDispatcher("/page.jsp#anchorName");
rd.forward(request, response);
Thanks
Cindy
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: forwarding to a page anchor
Posted by Bill Barker <re...@verizon.net>.
Duh, no. Anchor tags are only meaningful to the browser. They are stripped
from the request to the server (for e.g. <a href="mypage.jsp#anchorName>).
Using a RequestDispacher with an anchor will give a 404 error on all
versions of Tomcat. This is by design (since server-side it can't possibly
do what you think you want it to do :). Alternatives are:
1) use response.sendRedirect (so that the browser controls the anchor)
instead of rd.forward.
2) re-write page.jsp so that doing a:
<jsp:forward page="/page.jsp">
<jsp:param name="anchor" value="<%= anchorName %>" />
</jsp:forward>
has the proper JavaScript code to scroll to the "anchorName" tag.
"Cindy Ballreich" <ci...@ballreich.net> wrote in message
news:3.0.5.32.20020925164616.00c58390@urchin...
> I'd like to forward to an anchor <a name="anchorName"> in a jsp page, but
I keep getting a 404 error when I try to do it. It works from the browser,
but not from the server. Is it possible to forward to a page anchor like
this?
>
> RequestDispatcher rd =
> request.getRequestDispatcher("/page.jsp#anchorName");
> rd.forward(request, response);
>
> Thanks
>
> Cindy
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>