• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with user logout  RSS feed

 
Rajkumar balakrishnan
Ranch Hand
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
I develop an web application using JSP and Servlet. When the user login it goes to userhome page and when he click the logout link it goes to logout.jsp page. but the problem is when i click my browsers back button it shows the transaction held. How could i stop this. Here is my code

UserServlet.java
-----------------

int raj=modelBean.validateUser(username,password,role);
if(raj==1)
{
session.setAttribute("username",username);
if(session!=null)
{
getServletContext().getRequestDispatcher("/adminhome.jsp").forward(request,response);
}
else
{ getServletContext().getRequestDispatcher("/login.jsp").forward(request,response);
}
}

Here raj is the output of the validateUser() method that checks the DB for username and password. I set the value to 1 if data exists in DB.

Here my adminhome.jsp page
---------------------------

The userservlet redirects to the adminhome if values found in DB..

<% String sid=(String)session.getAttribute("username");
if(sid==null)
{
response.sendRedirect("expired.html");
}
%>
Then it displays a table about user information

Here is my logout page
----------------------

<%
session.removeAttribute("username");
if(session!=null)
{
session.invalidate();
}
%>

What should i do to avoid the problem...

Any help would be appreciated
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!