wood burning stoves
The moose likes Servlets and the fly likes Session Logout Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Session Logout Problem" Watch "Session Logout Problem" New topic

Session Logout Problem

vikka sharma

Joined: Jan 27, 2011
Posts: 3
I have one jsp in which i enter username and password.It calls another jsp which set loginId and some other stuff in session.Now when i click on one hyperlink which is calling a servlet through javascript function , in the servlet i use this code:-

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

HttpSession session = request.getSession(false);

RegistrationDAL registrationDAL = new RegistrationDAL();
ArrayList<ApprovalBean> appList = new ArrayList<ApprovalBean> ();
int tcount =0;
/*if (request.getSession().isNew()){

but for the first time it logout automatically .And after that it works perfectly .Can anybody tell me the reason of this behaviour.

Rajani Gummadi
Ranch Hand

Joined: Dec 17, 2010
Posts: 48
Hi Vikka,

There were numerous posts on this topic in this forum, which have clearly explained the solution and to avoid pitfalls. Some of those points I recollect is not to depend on session == null, to determine the logout functionality. Instead check for the existing of objects stored in session. You can also invalidate session, which in turns removes all the attributes added to session. Please go through those posts for better understanding.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63852

Rajani Gummadi speaks wisely -- heed his advice.

Some more advice: use bold sparingly and only for emphasis, rather than for entire posts. I have removed the bold for you.

Also, Pplease be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information.

Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link: http://aspose.com/file-tools
subject: Session Logout Problem
It's not a secret anymore!