I am making a project using MVC framework , where in i have created session on multiple pages and on every page there is an anchor tag displaying (logout) where it redirect user to the 1st page (Login Page). What i am trying to do is when user is redirected to the login page it checks that whether there is already an existing session if yes, then it Invalidate's the session and user has to login again. But my code doesn't work after invalidating the session when i click on submit without filling username/password it still takes the old value...please tell me where am i going wrong??
<jsp:useBean id="theBean" class="pack.java.MyModel"/>
<jsp:setProperty name="theBean" property="name" param="userName"/>
<jsp:setProperty name="theBean" property="pass" param="userPass"/>
<%@ taglib uri="/WEB-INF/jsp2/taglib1.tld" prefix="easy" %>
<html>
<head>
</head>
<body >
<form method="post">
<h1>Login please</h1>
Enter username : <input type = text name = userName >
</br>
Enter password : <input type = password name = userPass >
</br>
<input type = submit name = submit value = submit>
</br>
<%
HttpSession session=request.getSession(false);
if(session!=null)
{
session.invalidate();
}
String btn = request.getParameter("submit");
if(btn!=null)
{
%>
<easy:myTag/>
<%
}
%>
</form>
</body>
</html>