I am trying to figure out why I get two different session ids when I call two pages from the same web root. I thought I had declared the scope of each page properly, but the two pages will not "talk" to each other. I would appreciate anyone who can point me in the right direction for understanding what I'm doing wrong.
I'm working on code stored on a
Tomcat 6 server with
Java 6 on an Ubuntu server. Almost all the pages are written in
JSP (including the two I'm working on). The web root's index.jsp has code to check if a session variable "netID" is set. If not, it prints out a splash/log in page. If "netID" is a field in the HttpSession object, the user gets the main page, which is also part of the code in <WEBAPPS>/index.jsp. This output is controlled by very large "if...else" statement.
I have this page printing the username from this session and the ID to Catalina.out for
testing purposes. The page is set to session scope using a <%@page session="true" %> declaration, and also has a JavaBean which I believe is instantiating properly, as I can pass values in to it and call them out or call them without passing them in first.
There is another package, which has it's own login screen as this was absorbed from another department into our web schema. What was the web root of the second package was placed as a folder directly under the first package's web root, so that our schema is now:
<WEBROOT dir>
|
+-----index.jsp
|
<project2 dir>
|
+--index.jsp
This feeds from a MySQL database backend through JSP for the passwords and user data. Both contexts will pull from the database without issue, as this has been running for a little over two years now. I simply cannot get the session to be recognized in both locations. Instead, opening either page creates a session unique to that page, but:
Going to <WEBROOT>/index.jsp will give me a certain session ID (let's say ABC123), whereas going to <WEBROOT>/project2/index.jsp will give me a different session ID (XYZ789). If I refresh either page, I get the same ID. If I go back and forth, each page keeps it's own ID. If I:
1) go into <WEBROOT>/project2/index.jsp after restarting my server
2) load <WEBROOT>/index.jsp
3) open <WEBROOT>project2/index.jsp in a separate tab of the same window
I get project2's Session ID from step 1 showing up in step 3, which is what I would expect and proves that the server is finding Session IDs fine. I've checked my server's config files and found no instance of anything specifying separate Session IDs (although I only know enough from googling and checking other posts in here to make an attempt at verifying this, and claim no expertise).
My session declarations are as follows:
<WEBROOT>/index.jsp:
<WEBROOT>/project2/index.jsp
With bean declarations (currently removed) the code was:
<WEBROOT>/index.jsp:
<WEBROOT>/project2/index.jsp:
<WEBROOT>/index.jsp called the setUser() method of admin103.userBean explicitly in the jsp code, passing it an object of type supportUser (an internal naming convention). I had originally planned to create a class userProfile and assign it to the session as an object, but that failed too due to the session IDs being different. I'm convinced I'm just not understanding some detail about how Session IDs are assigned. Could anyone point me in the right direction to figure out what I'm missing?