Solved

Cookieless Session in Tomcat

Posted on 2008-06-17
5
1,346 Views
Last Modified: 2013-11-24
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
Comment
Question by:william007
  • 3
5 Comments
 
LVL 92

Expert Comment

by:objects
ID: 21801049
try setting cookies to false in the context definition

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

0
 
LVL 92

Expert Comment

by:objects
ID: 21801075
I read that wrong. You need to handle it yourself, an I think jstl handles it for you.

0
 
LVL 92

Assisted Solution

by:objects
objects earned 100 total points
ID: 21801088
0
 
LVL 27

Accepted Solution

by:
rrz earned 400 total points
ID: 21802771
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
 
LVL 9

Author Comment

by:william007
ID: 21836870
Thanks:)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Which is the latest version of Apache Tomcatl 3 67
more than one jdk and one jre 1 57
ejb mdb examples 1 19
SequenceInputStream example 3 21
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question