This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I'm trying to figure out why when I click a link on a jsp with a hash in the URL the jsp is not reloaded, but when modifying the hash using document.location.hash the jsp is reloaded. For example, if I have a link on my page www.mydomain.com/index.jsp that look like this:
<a href="#index1">index 1</a>
When I click the link the address bar is updated to www.mydomain.com/index.jsp#index1 and the jsp is not reloaded.
Similarly, if I manually edit the URL in the address bar and attach a hash to the end of the URL and hit return, the page is not reloaded.
However; if on some user action I manually update the hash using
location.url.hash = "index1";
The address bar is updated just as before, but the jsp is reloaded in this case.
Actually, reloaded, is not what is happening exactly, because the document onload is not being called; however the jsp is being re-executed. Placing a breakpoint in the jsp verifies this.
This is driving me crazy and screwing up the desired behavior of my site.
I've spent many hours searching for answers, but everything I read indicates that a page does not reload when the hash is updated. I have been unsuccessful in finding any information on the behavior of a jsp in this case.
In all cases I would like the page to behave as if the user clicked a link and not have the jsp re-executed.
Any insight anyone could offer would be greatly appreciated.
Joined: Oct 13, 2011
This seems to be a bug with Chrome and Safari. Behavior is as expected on IE, Firefox, and Opera.