File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Servlets ...             Intresting One....... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlets ...             Intresting One......." Watch "Servlets ...             Intresting One......." New topic

Servlets ... Intresting One.......

ninad parkhi

Joined: May 04, 2001
Posts: 25
I am having servlet as User Interface(say servlet1) which accepts few inputs from user.After user presses SUBMIT button new Servlet is loaded on the same page (say servlet2).
Now if user presses BACK button of browser he/she goes back to servlet1 and can view the information he/she has entered.
I want that user should not able to view this information(which was previously entered)
Pl reply immediately.............
Happy Singh

Joined: May 02, 2001
Posts: 5
Search for this in HTML and Javascript forum..
AND PLZ DON'T POST 2 posts with the same question, that too during the same time period.
good luck :-)
Maky Chopra
Ranch Hand

Joined: Apr 11, 2001
Posts: 149
You seem to think that a servlet is a magic pill to solve all your programming problem. There is a saying in the software world, that if the only tool you have is a hammer, all the problems begin to look like nails.
In the future, before posting here, please bear in mind that a servlet executes on a server and generates dynamic html to send to a browser.
To answer your questions (which has nothing to do with servlets),in older browsers you could use Javascript to delete the browser history, but as this became a security issue - JS cant touch the history except for navigation (history.go(3), history.go(-3)etc) now in the newer versions.
However, the closest workaround I can think of is to spawn new browser windows with each submit....the NEW loading window should be coded to close the old EXIT window..hence you can perpetually not have a back button that is enabled (no history is carried over from window to window).

[This message has been edited by Mak Bhandari (edited May 04, 2001).]
Sean MacLean
Ranch Hand

Joined: Nov 07, 2000
Posts: 621
Here's what to do in your Servlet 1. Before you write the form to the client (i.e. the first thing you should do) is the following
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "Thu, 01 Dec 1994 16:00:00 GMT");
There's nothing magic about that date - it's just old enough to invalidate the form's cached content in the browser.
ninad parkhi

Joined: May 04, 2001
Posts: 25
Thanks Sean & Mak
You solved my problem ........

David O'Meara

Joined: Mar 06, 2001
Posts: 13459

an extended version of the same:

I can't take credit for this (assuming it works, I haven't tried it), it was posted a few days ago. Note that the behavior is still Browser dependent so this isn't in any way the 'ultimate fix'.
<read that hammer and nails quote above and pretend it's my .sig>
I agree. Here's the link:
subject: Servlets ... Intresting One.......
It's not a secret anymore!