Session mix-up
Hi..
im having problem with session in servlets.. my application uses jsp, servlets and ejbs..
when i login and go thru modules of applications, sometimes session mixes-up with other users. and im getting other users information instead of mine.
pls do suggest me in this...
thnx in advance...
Hi,
U get session-id and compare it with the previous page's session.
HttpSession session = request.getSession(true);
ses_id = session.getId() -->this will return session-id associated with this session.
Before going to next page, set the session attribute like,
session.setAttribute("ses_id" , ses_id);
and in the next page retrieve it as,
session.getAttribute("ses_id"); and compare with the current session.
Hope this would help u.
> Are you sure it is the session that is getting mixed
> up and not something else? Make sure that none of
> your servlets are using instance variables to hold
> information specific to a request. Multiple threads
> of your servlet could be running simultaneously and
> the inappropriate use of instance variables could
> result in the "mix-up" of data between multiple
> sessions.
Yes indeed, a lack of thread safety will cause this.
%