
Hii Sir, I have to make a login and logout page with sessions .Now i have to invalidate
the session after a certain interval of time and after clicking logout button.Means that
after session expiry time and logout action no one can access previous pages by clicking
back button of browser without again logging.
Plz sir give me the full working code of this .It is the starting need of my project.
Thank you Sir.

Use session.invalidate() method to close the session.Here is an example.
1)login.jsp:
<html> <head> <title>User Login</title> </head> <br> <body Bgcolor ="#0099cc"><hr><hr> <form method="POST" action="action.jsp"> <p><b>UserName:</b> <input type="text" name="UserName" size="10"></p> <p><b>Password:</b> <input type="Password" name="Password" size="10"></p> <p><input type="submit" value="Submit" name="submit"><input type= "reset" value="Reset" name="reset"></p><hr><hr> </form> </body> </html>
2)action.jsp:
<%@page import="java.util.*" %>
<script>
function go() {
window.location.replace("logout.jsp",'window','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
self.close()
}
</script>
<%String str = request.getParameter("UserName");
session.setAttribute("UserName", request.getParameter("UserName"));%>
Welcome to <%= session.getAttribute( "UserName" ) %>
<% if (session.getAttribute("UserName").equals("")){%>
<a href="login.jsp"><b>Login </b></a>
<%}
else{%>
<a href="javascript:go()"><b>Logout</b></a>
<%}
%>
3)logout.jsp:
<%session.invalidate();%> You have logged out. Please <a href="a.jsp"><b>Login</b></a>

Thank you very much for your quick response. But Sir According to my need the session should be expired automatically after certain time.

brother u have to change session time out in web.xml file..according to ur needs