Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 5th, 2002, 06:51 AM
tiago251 tiago251 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 14 tiago251 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
session information lost from one servlet to another - session id changes

Hi everyone!

I made an web application based on 2 servlets (two different packages). One package imports the other.

In the first one (used for login - logoff purposes) I store a string "strEmployeeID" in the session. But when I link (html) to the second servlet, this information is lost. (Two different folders, one for each component, but in the WEB-INF\classes folder there are both packages with all classes for the two servlets).

Searching a bit, with session.getId(), I remarked that the sessionId changes too, without closing the browser window, which normally shouldn't happen...of course if it isn't the same session, all the information relative to it is lost.

Does someone have an idea why the session changes? Should I use the context instead of the session? Running Tomcat 4.0 on Explorer 6.0.2600.

Thanks a lot for your help!
Tiago

Reply With Quote
  #2  
Old October 6th, 2002, 06:58 PM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
What are the urls to the two servlets? And what code are they using to get the session?

Reply With Quote
  #3  
Old October 7th, 2002, 07:06 AM
tiago251 tiago251 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 14 tiago251 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Re:

The two servlets are in:

work/package1/WEB_INF/classes/*.class

and

work/package2/WEB_INF/classes/*.class


And from jsp files in /package1/ there are html links to package2 like:
<a href="../../package2/servlet/servletName">link</a>

The code I use to get the session is:
Code:
HttpSession session = request.getSession();


Hope it helps...I read something about session scope but don't know if there is something to do with it...

Thanks!
Tiago

Reply With Quote
  #4  
Old October 7th, 2002, 10:26 AM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
Ya, your servlets are in different contexts, so they won't be able to share sessions. You're going to need to put them both into the same WEB-INF/classes folder.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > session information lost from one servlet to another - session id changes


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway