aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes JSP reloads on hash change Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JSP reloads on hash change" Watch "JSP reloads on hash change" New topic
Author

JSP reloads on hash change

Warren Marble
Greenhorn

Joined: Oct 13, 2011
Posts: 2
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

Joined: Oct 13, 2011
Posts: 2
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

Joined: Jan 10, 2002
Posts: 61218
    
  66

Welcome to the Ranch!


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP reloads on hash change