Solved

Cookieless Session in Tomcat

Posted on 2008-06-17
5
1,332 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
java continue statement 10 112
Tools or ways to handle development of complex web applications 4 99
ArrayIndexOutOfBoundException 9 66
stackato and cloud 4 64
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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.

929 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now