I have a form that contains some textboxes to fill some info..after submited the form it will redirect to another page. I need to prevent user to view the page again by pressing back botton.

Ravi Verelly

We can accomplish this with using both jsp and JavaScript.
<script language="JavaScript">
var prevpage = "<%=session.getValue("prevpage")%>";
if (prevpage=="result.jsp") { window.open("redirectpage.jsp","_parent");

<% session.putValue("prevpage","confirm");//reset the variable %>

Set the prevpage variable in this page.
<% session.putValue("prevpage","result.jsp"); %>

When first time form.jsp loads, it will check for the prevpage variable. Since the prevpage is not set it displays the form.jsp page. Then we submit this page to result.jsp
If we hit back button from result.jsp, we will be redirected to redirectpage.jsp.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact