hi all, i tried following code for session management bt i dnt knw where it went wrong? can anyone please help me solve the problem. i want to restrict user going on the prevoius page after logging out when he clicks on the browser's BACK button.

******************************************************************
1) i created login.jsp as follows:

<p><a href="1.jsp">1</a></p>
   <%@ page contentType="text/html;language="java" import="java.sql.*">
   <%
	String username="vishal";
	request.getSession();
	out.println("<br>new session created");
	session.setAttribute("username",username);
	out.println("<br>"+session.getAttribute("username"));
   %>

*********************************************************************
2) then i created 1.jsp as follows:

<%@ page contentType="text/html;language="java" import="java.sql.*" %>
<html>
<body>
<p><a href="logout.jsp">logout</a></p>
<%
	if(session.getAttribute("username")==null)
		response.sendRedirect("Error.htm");	
%>
</body>
</html>

**********************************************************************
3) logout.jsp would be :

<%
	if(session.getAttribute("username")==null)
		response.sendRedirect("Error.htm");	
	else
	{
	  session.setAttribute("username",null);
	  session.invalidate();
	  response.sendRedirect("login.jsp");
	}
%>

*********************************************************************

but above code is not working. can anybody solve this problem? pls? or at least give some modification to it???

sorry but above link is broken..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.