It's not a secret anymore!
The moose likes JSP and the fly likes Anchor target in dispatcher forwards Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Anchor target in dispatcher forwards" Watch "Anchor target in dispatcher forwards" New topic

Anchor target in dispatcher forwards

Mary White
Ranch Hand

Joined: Jan 27, 2003
Posts: 41
I'm trying to use anchor targets in the <forward> tag of and <action> in the struts-config.xml.
I using the following approach:
<forward name="success" path="/client/ClientInfo.jsp#details" redirect="true"/>
Although the page is presented, the anchor target is ignored.
I already tried accessing the page directly from the browser address and the anchor target works fine. It's only ignored when I try to access it from the struts-config file.
Any Idea?
[ October 21, 2003: Message edited by: Bear Bibeault ]
Terry Martinson
Ranch Hand

Joined: Oct 18, 2003
Posts: 293
I'm trying to do a similar thing and also can't get this to work. I tried building a new ActionForward by appending on the anchor tag in an action class, but that also does not work.
In the depths of the Struts RequestProcessor code, they use a RequestDispatcher to do the actual forwarding. The API for RequestDispatcher says that it "sends them to any resource (such as a servlet, HTML file, or JSP file) on the server". So, it looks like whatever path the ActionForward is sent to is the actual file name destination. (i.e. If ActionForward path is "/someplace/foo/Bar.jsp#MyAnchor", the RequestDispatcher will actually look for that filename, including the #MyAnchor, on the server.) I proved this out by putting an actual file name including the anchor out there, and it does find it.
Has anyone figured out a way to deal with anchors in the Struts framework?

Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

This is actually JSP-related, not Struts-related. Here's a solution:
Moving this thread to the JSP forum.

Junilu - [How to Ask Questions] [How to Answer Questions]
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63857

I also modified the subject to make it easier for future searchers to find.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Anchor target in dispatcher forwards
It's not a secret anymore!