aspose file tools*
The moose likes Servlets and the fly likes session ID changes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "session ID changes" Watch "session ID changes" New topic
Author

session ID changes

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
hi,
i have a problem, such that the session id changes on the way from one page,servlet to another. cookies are enabled. there should be no problem.
by the way, i am using tomcat 4...
when I first create a session, use: request.getSession(true);
and later just use request.getSession(false); -->then get problems. null objects etc.
isSessionfromCookie returns always false....
why might this happen?
[ August 28, 2003: Message edited by: R�stem e Zal ]
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Is cookies enabled at the client side?


Groovy
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
jeah, cookies are enabled...
i have a proposal.
Since session info is somehow transferred over Cookie. i made a short investigation over the forum.java.sun.com and got this:
the cookie is transferred only to those directories: at the same level or below the directory from which the cookie was sent to the client...
ex. if i have www.xyz.com/login_page.jsp ---> /servlet/MyServlet1 which implicitly does some processing(checks login name password) (creates session here) and redirects to ---> /jsp-pages/page2.jsp if password ok, or back to page1.jsp o.w.
does any of you have any idea?
[ August 28, 2003: Message edited by: R�stem e Zal ]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12805
    
    5
Possibly the way your pages are organized in directories, the servlet engine thinks you have more than one "web application"
Also, if you are using the /servlet/xxxx nomenclature it goes through the "invoker" servlet so the association with the other parts of your "web application" may not being made.
Tell us more about how your directories under /webapps/ are laid out.
Bill
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944

/myappln/index.html--> /myappln/jsps/jsp1.jsp --> /myappln/Servlet1 (deployment descriptor defined) --> /myappln/Servlet2 --/myappln/jsp2.jsp .....
session is created first in jsp1.jsp in Servlet1, but inside Servlet1 the id has changed strangely, and the attribute I have put while inside jsp1.jsp has disappeared. also from S1-->S2 the id changes again. -->and so on to jsp2.jsp
ANOTHER Strange issue: i write sometimes values to the console, they are printed twice..
thanks in advance.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Are you using session.invalidate somw where?
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
No, nowhere session.invalidate(); being used...
actually this is an appln with about 10 servlets 5 beans, 4 tags, and 15 jsps , + htmls css image files.. and the whole appln was working ok till last week. but since 2 days ridicuolously has this problem. i am still testing it..
is it related with tomcat? i dont know.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

ANOTHER Strange issue: i write sometimes values to the console, they are printed twice..

Check whether some where in your JSP you have submitted twice.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
throughout my investigations, the sessionId (session.getId() ) is the same through the journey, but nevertheless when i look at the session, the session object is changing. should the session object be constant, or both the session object and the session Id? what is the proper solution?
But still within the session, the attributes all are strangely set to null.
the twice being printed out problem I couldnot solve either. but i am using javascript while sending the form, so that it is not being submitted twice...
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Session object is same for the same session id for a client.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi guys, finally solved the issue...
when the form is at the beginning submitted, somehow the Tomcat engine interpretes it as two different submissions.
I rebooted the computer; now still it has two submissions. but the session issue has been working properly.
Regards...
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Have you defined a function for submit button ?
 
 
subject: session ID changes