aspose file tools*
The moose likes JSP and the fly likes Can I control histosy the history in the browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Can I control histosy the history in the browser " Watch "Can I control histosy the history in the browser " New topic
Author

Can I control histosy the history in the browser

Sayantan Majumdar
Greenhorn

Joined: Sep 28, 2008
Posts: 16
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?
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

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?


Steve
 
Consider Paul's rocket mass heater.
 
subject: Can I control histosy the history in the browser