Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Back button

 
Viet Jav
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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.
JV.
 
Sagar J Jambhulkar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic