tags:

views:

48

answers:

1

hi all,

i have a jsp page login.jsp, which checks for username and password and when submitted forwards to another page display.jsp . All i need to do is when i hit the backspace key or back button in browser i should display the same display.jsp instead of going back to login.jsp. please help me with any ideas and code snippets.

A: 

Here is some code you can put in your login.jsp that will force a redirect to your display JSP if the user is already logged in. You just have to fill in the test and the URL to redirect to.

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%-- If user is not logged in or is not an admin, dispatch to the login page --%>
<c:if test="${some test for 'user is logged in'}">
  <c:redirect url="/display/jsp/path.jsp"/>
</c:if>
Eddie
The problem with this solution, being that if the page is in the cache, then it will be served from the cache, and this code won't be re-evaluated. Hence you will get the login page.
evnafets
JSPs should *never* be served from the cache!
Eddie