• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1427
  • Last Modified:

Cookieless Session in Tomcat

I am using Tomcat 6.0

I am developing jsp pages for mobile devise and some of them do not support cookie. Thus I need to use cookieless session.

What I am doing now is to manually append the session id as querystring, and using session handler(a listener) to get the session by id. Is there any auto URL rewriting approach in Tomcat that we can make use of so we do not need to manually append the querystring, and manually populate the session by the session id?
If yes, how to configure it?

Thanks a lot!!
0
william007
Asked:
william007
  • 3
2 Solutions
 
objectsCommented:
try setting cookies to false in the context definition

http://tomcat.apache.org/tomcat-6.0-doc/config/context.html

0
 
objectsCommented:
I read that wrong. You need to handle it yourself, an I think jstl handles it for you.

0
 
rrzCommented:
If you are not using JSTL as suggested by objects, then you could use the encodeURL method.    
Here is a page that demonstrates the method.  Use the encoded url to increase the hit count when cookies are not used.  
<%
  String url = request.getRequestURL().toString();
  String encoded = response.encodeURL(url);
  Integer count = (Integer)session.getAttribute("count");
  if(count==null)count = new Integer(0);
  session.setAttribute("count",new Integer(count.intValue() + 1));
%>
sessionId=<%=session.getId()%><br/>
isNew=<%=session.isNew()%><br/>
fromURL=<%=request.isRequestedSessionIdFromURL()%><br/>
fromCookie=<%=request.isRequestedSessionIdFromCookie()%><br/>
url=<%=url%><br/>
encoded=<%=encoded%><br/>
<a href="<%=url%>">Not encoded request</a><br/>
<a href="<%=encoded%>">Encoded request</a><br/>
count=<%=count%>   <br/>
0
 
william007Author Commented:
Thanks:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now