JSP/session question

M

Michael

Hej Alle!

I'm trying to get this very simple jsp page to work under Tomcat 4.1.x (x=24
and 27, with similar results):

--------------------------
<HTML>
<HEAD>
<TITLE>sessiontest.jsp</TITLE>
</HEAD>
<BODY>
Current value of A is: <%= session.getAttribute("A") %><br>
Now we set the value of A to "george"..<%
session.setAttribute("A","george"); %>..done!<BR>
<BR>
Just to verify, here's A again: <%= session.getAttribute("A") %><BR>
<BR>Now <A href="sessiontest.jsp">reload</A> the page.
</BODY>
</HTML>

--------------------------

When I load the page, everything works as expected. A begins with a null
value, is then set to "george" and this is verified in the last line of
output.

But when I click the link to reload the page, A once again starts as null.
In other words, a new session is created each time the jsp page is loaded.

I have run this exact page under WebSphere 5, and it appeasrs to work as
intended - i.e. the second time the page is loaded, A is already initialized
with "george".

Can anyone tell me what is going on here? What am I doing wrong?

(Please do not ask me to use jsp:useBean - the above is a simplified example
of what I really want to do, which involves setting session attributes from
inside custom tags etc. I really need to set the values using the session
object).

My IE cookie settings are normal, and I'm not using a proxy server.

Mvh
/Michael
www.hyperpal.com
 
R

Ryan Stewart

Michael said:
Hej Alle!

I'm trying to get this very simple jsp page to work under Tomcat 4.1.x (x=24
and 27, with similar results):

--------------------------
<HTML>
<HEAD>
<TITLE>sessiontest.jsp</TITLE>
</HEAD>
<BODY>
Current value of A is: <%= session.getAttribute("A") %><br>
Now we set the value of A to "george"..<%
session.setAttribute("A","george"); %>..done!<BR>
<BR>
Just to verify, here's A again: <%= session.getAttribute("A") %><BR>
<BR>Now <A href="sessiontest.jsp">reload</A> the page.
</BODY>
</HTML>

--------------------------

When I load the page, everything works as expected. A begins with a null
value, is then set to "george" and this is verified in the last line of
output.

But when I click the link to reload the page, A once again starts as null.
In other words, a new session is created each time the jsp page is loaded.

I have run this exact page under WebSphere 5, and it appeasrs to work as
intended - i.e. the second time the page is loaded, A is already initialized
with "george".

Can anyone tell me what is going on here? What am I doing wrong?

(Please do not ask me to use jsp:useBean - the above is a simplified example
of what I really want to do, which involves setting session attributes from
inside custom tags etc. I really need to set the values using the session
object).

My IE cookie settings are normal, and I'm not using a proxy server.

Works fine under Tomcat 5.0.16, and I use 4.0/4.1 frequently and haven't had
that problem with them. I'm no Tomcat guru, but there may be a server
setting that's been changed.
 
M

Michael

Hi,
Works fine under Tomcat 5.0.16, and I use 4.0/4.1 frequently and haven't had
that problem with them. I'm no Tomcat guru, but there may be a server
setting that's been changed.

Could you verify if it actually does work under 4.1.24 for example?

Also, the Tomcat installation is pretty much "out of the box" as far as
server settings are concerned. Do you have any suggestions as for which
settings could be affecting session behaviour?

I guess I could just try it under 5.x and see what happens, but the problem
is that my app must work in a hosted environment where I do not have total
control over the software.

/Michael
www.hyperpal.com
 
M

Michael

Hi all,

Apparently Tomcat does not function properly with document context names
containing blanks. After changing the webapp to use a simple one-word
document root, everything worked.

I guess I should have known better, but OTOH Tomcat should be able to handle
context roots with blanks, if WebSphere can do it without problems.

/Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top