• Post Reply Bookmark Topic Watch Topic
  • New Topic

Adding URL to history in JSP without JavaScript  RSS feed

 
Sam Gardner
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all -

I am working on trying to get a single page added to the history without using JavaScript.

Basically, I'd like to redirect from a page automatically, (ie, without the user seeing the content on the page), but have them be able to hit the back button on that browser and go back to the page they were redirected from.

I've tried using "response.sendRedirect("new_page.jsp") but that forwards before rendering the HTML, so the URL isn't written into the history (at least, that's what I'm guessing is happening).

Does anyone have any idea how I could get this implemented?

Thanks for the help.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It might be difficult without seeing the content at all, especially if you want them to be able to navigate back to the page whose content they will not have seen.

A meta refresh will show the content, but will also leave a history (at least in FF; don't know about IE).
 
Sam Gardner
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:It might be difficult without seeing the content at all, especially if you want them to be able to navigate back to the page whose content they will not have seen.

A meta refresh will show the content, but will also leave a history (at least in FF; don't know about IE).


That's the other option I considered, but I was having some weird flashing issues in IE 6 when I was using the meta refresh with the period set to 0. Unfortunately, the current project has a high likelyhood of users with IE 6, so I'd rather not use something that would result in any sort of poor behavior on that browser.

Since I am trying to work with the back button here, is there any way to detect without JS that the back button has been pressed? I'm assuming no, but can't hurt to ask.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
None that I know of, but that doesn't mean much.

I'm not really sure your requirements are 100% meetable, but I'm far from an HTML/browser expert.
 
Sam Gardner
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:None that I know of, but that doesn't mean much.

I'm not really sure your requirements are 100% meetable, but I'm far from an HTML/browser expert.


Yeah, that's what I'm starting to think as well. Through some testing, even the meta-refresh isn't writing to the history in the latest FF beta. I'm using a bunch of session/request parameters to handle the navigation through some forms, and the back button functionality doesn't restore or modify any of the session variables, or even re-evaluate the Java code on the returned-to page, so I need some way to disable or otherwise modify the back button's behavior to work correctly.

I was hoping to avoid JavaScript, but I guess I don't have much choice now.

Thanks for the help.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Searching the web will return a million hits on how to deal with stuff like that; often not caching is enough.

(Except for your redirect/history/but-back-still-works thing, which I suspect may lie out of reach.)
 
Sam Gardner
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:Searching the web will return a million hits on how to deal with stuff like that; often not caching is enough.

(Except for your redirect/history/but-back-still-works thing, which I suspect may lie out of reach.)


Holy crap, disabling caching did the trick. No need for the weird redirect hack any more.

Thanks a ton for the tip!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!