• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

go back history

 
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was putting this code in my jsp page if error occured
<a href="javascript:history.go(-1)">Click here to go back</a>
Now beside forward back, i want to do something in my java code and then forward back, how i can "memorize" the previous page?
Can any one of the HttpServletRequest method help me? getRequestedSessionId() or getRequestURI() ?
Thanks!
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by "do something in your Java code"? You can call Java code directly from the JSP code itself, through a scriptlet, bean, or custom action. That avoids the whole problem.
If you want to remember the previous page, though, it's trivial to store it in the session object at the beginning of each request using HttpServletRequest.getRequestURI(). You can then offer a link to that URI.
Chris
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you choose to use javascript:history.go(-1) there is nothing you can do. the whole process is 100% client-side and involves no extra http connection back to your server. Simply put, that javascript intructs your browser to step back, grabs the copy from browser's cache, and display. Some browsers are "smart" enough to remember what you've entered in the previous page, but it's not consistent.
Avoid using javascript if you want to guarantee this "memorizing" feature, as suggested by Chris.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic