• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Can I control histosy the history in the browser  RSS feed

Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing a problem like, I have a search page developed in JSP. I dont want the browser to record the histroy of this search page. Like, if I search 4 items, one click on the browser back button should navigate to the page from where I came to the search page and not the 3 rd search page. Is it possible?
Posts: 4179
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you can't control the browser's history in JSP. You may be able to screw with it with JavaScript but that is fragile and not very user-friendly. What you should do is use a combination of:
1) Cache-Control headers so the browser doesn't remember previous searches
2) A Page / Front Controller servlet that receives the search results, gathers the required information, and then uses response.sendRedirect() to the JSP page for display.
3) A recognition sequence token so when the results are requested again via a back button the server sees that the page being requested is improper and can forward to the search page again.

But are you sure you want to do this? It is rather useful for searches to be stored locally and referred to again later if the user wants to go back and see his previous results, or to save a search in bookmarks and refer to it often (or email to a friend, etc...). Will you be disrupting the user-experience by forcing them to make their searches over and over again?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!