Problem using HTML bookmarks with jsp and <BASE> tag

Hi,

I have a JSP (abc.jsp) that has a <BASE href = "http://www.xyz.com" >. It also uses a html bookmark "abc.jsp#top" to provide a "Top" link for the user to go to the top of the page.

This page is viewed for the first time through a Request dispatcher's forward method from a Servlet. It uses some attributes by calling "request.getAttribute("...") method.

Now if the user clicks on the "Top" link, it goes to the jsp directly ( Not through the forward method of RequestDispatcher). It starts giving a problem in request.getAttributes.

How can I work around this problem? Any suggestions?

Thanks in advance!

Sridhar Mudugu

[717 byte] By [SridharM] at [2007-9-26 2:05:14]
# 1

Hi,

Instead of the abc.jsp#top href, you should use the URL that is used to retrieve the page. This URL most likely is the URL to your dispatcher servlet, and some parameters.

E.g. if your dispatch servlet is mounted on "/servlets/dispatch", and the desired page can be retrieved using "/servlets/dispatch?param1=qwas", then the href you should use is:

"/servlets/dispatch?param1=qwas#top"

You can construct the URL that was used to retrieve the page by using methods from the HttpServletRequest. This prevents hardcoding URLs in your pages.

Cheers,

--Arnout

ajkuiper at 2007-6-29 8:50:01 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Arnout,Thank you very much.That solved my problem. Sridhar.
SridharM at 2007-6-29 8:50:01 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...