This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Servlets and the fly likes Back button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Back button" Watch "Back button" New topic

Back button

Viet Jav
Ranch Hand

Joined: Dec 27, 2001
Posts: 55
How to when a user click on the back button of the browser an expire message will appears?.
I have 2 JSP A and B
In A page: user use thid page to register his data. After finishing input data, he click Submit button--->his data will insert into DB by Servlet and then forward(B page)display B(notice insert sucessfully!).
On B page, when user click Back button if browser---> A page display.

I want when user click Back button on B page ----> Expire message page display.
How solve my problem?

The following are my code, but not work:
On top of my A and B page:

<%@ page language="java" contentType="text/html; charset=ISO-2022-JP" %>

<% response.setHeader("Pragma","no-cache");%>
<% response.setHeader("Cache-Control","no-store");%>
<% response.setDateHeader("Expires",-1);%>

Your help is appriciated.
Sagar J Jambhulkar

Joined: Sep 10, 2004
Posts: 8
try this

response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server

also this should be at the top of page.meaning before any output is commited cos these are HTTP headers we are setting

Love Work and Bless All and you will be blessed by God<br />-----Sadguru Wamanrao Pai
subject: Back button
It's not a secret anymore!