Skip to main content

No managed session attribute.

2 replies [Last post]
jameshr
Offline
Joined: 2008-01-31
Points: 0

My web app deploys fine but I can NOT get it to maintain a session attribute. Given the following simple test.jsp:

<%@ page import="java.util.*"%>
session.isnew=<%=session.isNew()%>
attr=<%=(String)session.getAttribute("test")%>
<%
session.setAttribute("test", "testval");
%>

The above continuously returns the same output on every page hit of the same session:

session.isnew=true
attr=null

Instead, I expect to see:

Hit #1:

session.isnew=true
attr=null

Hit #2:

session.isnew=false
attr=testval

And so on. Why is every hit of the same session treated as a "new" session?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
rlubke
Offline
Joined: 2003-08-21
Points: 0

Your test case runs as expected against GFv2UR1 in my environment.

My guess is your browser didn't accept the cookie. If the cookie isn't being used, then that implies url rewriting. Because this case is simple and there are no URLs with the session info encoded to re-access your test, the container assumes the session wasn't joined and returns this result.

I'm guessing if you add a link with the href value as:

<% out.print(response.encodeURL("test.jsp")); %>

Make the initial request, then click the link, you'll see session.isnew=false attr=testval

rlubke
Offline
Joined: 2003-08-21
Points: 0

Your test case runs as expected against GFv2UR1 in my environment.

My guess is your browser didn't accept the cookie. If the cookie isn't being used, then that implies url rewriting. Because this case is simple and there are no URLs with the session info encoded to re-access your test, the container assumes the session wasn't joined and returns this result.

I'm guessing if you add the following to your test:

">click

Make the initial request, then click the link, you'll see session.isnew=false attr=testval