new session created with every page request

Hi,

I have an application running in portal framset. A user logins into a portal and has access to several applications, that are displayed in a frameset. My application is creating a new session for every page in the application. Of course, I can't keep session variables and a large amount of sessions are being created. What could be the reason for this, and is there a work around?

Thanks.

[413 byte] By [helsings] at [2007-9-30 21:10:07]
# 1
Do the following:1. web.xml has session config make sure its set to what you want.2. Make sure session="boolean" is set correctly3. Make sure your code is not invalidating your sessionThat's it.
tberthel at 2007-7-7 2:43:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

There is a chance the you have cookies turned off. Sessions are maintained via a jsessionid which is stored in a user cookie. If you (or another user) don't use cookies, then the session will be lost.

To fix this, every URL you use must be encoded, such that, if cookies are not used, the jsessionid is attached to the end of the URL. If you are using JSTL, the easiest way to do this is like this:

<c:url var="formAction" value="someOtherPage.jsp"/>

<form action="<c:out value="${formAction}"/>" method="GET">

//...

<c:url var="nextPage" value="nextInLine.jsp"/>

<a href="<c:out value="${nextPage}"/>">Next</a>

Or if you are not using JSTL, you can use scriptlets:

<%

String formAction = response.encodeURL("someOtherPage.jsp");

%>

<form action="<%= formAction %>" method="GET">

//...

<%

String nextPage = response.encodeURL("nextInLine.jsp");

%>

<a href="<%= nextPage %>">Next</a>

stevejluke at 2007-7-7 2:43:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

thank you all,

i am rewriting the url, and the users session is persistent. so that is good. but still my session listener tells me there is a new session created with every page request. i might try disabling cookie tracking.

i am using tomcat 5.0. I hear that I can set a context.xml file and set a context param so cookies = "false". i am not sure what to name the file, where to put it, or the syntax of the param. anyone ever done this before.?

thanks ~steve

helsings at 2007-7-7 2:43:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
This document should help you out http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/context.htmlThe xml file name should be context.xmlIt should be put in the META-INF directory of your WAR (which is how you should deploy your app, take a google for Tomcat Deploy
stevejluke at 2007-7-7 2:43:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...