Solved

Cookieless Session in Tomcat

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

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 …
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.

746 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

12 Experts available now in Live!

Get 1:1 Help Now