File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes jsp session keeps changing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp session keeps changing" Watch "jsp session keeps changing" New topic
Author

jsp session keeps changing

tatyana markova
Greenhorn

Joined: Mar 12, 2004
Posts: 1
How do I keep my jsp session from changing.
It only changes when I use the URL that is mapped to my web server. If I access my server using localhost, then the session does not change.
I would really appreciate any help with this.
Thanks,
Tatyana
Tatyana1217@yahoo.com
Alfonso Harding
Ranch Hand

Joined: Feb 09, 2002
Posts: 35
Try using at the top of your code.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
You will get a new session every time you call the server at a given address for the first time from a given browser instance.
Subsequent calls to the same server from the same browser instance will use the same session unless you specifically tell it not to by calling session.invalidate() somewhere in your code or if you wait longer than the set session timeout interval.


42
Jeffrey Spaulding
Ranch Hand

Joined: Jan 15, 2004
Posts: 149
Hi,
the session mechanism uses either URL rewriting or a session cookie on
the client side.
If your browser has disabled session cookies, you will get a new session every time your page calls itself with a

or with a


To make sure your page adds the session id to the URL you can use

and work with the url variable from then on.
Bye,
J.
Hans Bergsten
Author
Ranch Hand

Joined: Dec 01, 2003
Posts: 106
Originally posted by Jeffrey Spaulding:
Hi,
the session mechanism uses either URL rewriting or a session cookie on
the client side.
If your browser has disabled session cookies, you will get a new session every time your page calls itself with a

or with a


To make sure your page adds the session id to the URL you can use

and work with the url variable from then on.
Bye,
J.

Correct. An alternative to a scriptlet that calls encodeURL() is to use the JSTL <c:url> action:
<c:url var="myURL" value="foo.jsp">
<c:param name="myParam" value="myValue" />
</c:url>
<a href="${myURL}">myLink</a> (if you use JSP 2.0)
<a href="<cut value="${myURL}" escapeXml="false" />">myLink</a> (if you use JSP 1.2)
The <c:url> action takes care of both "URL rewriting" (including the session ID in the URL), "URL encoding" of the parameter value (e.g., converting special characters to character entity codes), and converting context-relative paths to absolute paths that the browser understands.


Hans Bergsten, hans@gefionsoftware.com<br />Author of O'Reilly's<br />- JavaServer Pages,<br />- JavaServer Faces<br /><a href="http://www.hansbergsten.com/" target="_blank" rel="nofollow">http://www.hansbergsten.com/</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp session keeps changing
 
Similar Threads
Loosing sessions between pages
How to change session tracking lifetime in JSP
Changes in JSP after jsp precompilation
Getting Undesired Characters in My Strings
Prefer hidden field instead of session attribute