Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP reloads on hash change

 
Warren Marble
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All,

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.

Thanks,
W. Marble
 
Warren Marble
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Update.

This seems to be a bug with Chrome and Safari. Behavior is as expected on IE, Firefox, and Opera.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic