tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roland Nygren" <>
Subject RE: How to keep same thread during a session
Date Thu, 21 Aug 2003 15:02:08 GMT

Sounds good.
I would
In the servlet where the session is created I would store the CallId with
session.setParameter("CallId", callId);
callIdListSingleton.set(Thread.currentThread().hashCode() , callId);

and the in all other servlet / JSPs
int callId = session.getParameter("CallId");
callIdListSingleton.set(Thread.currentThread().hashCode() , callId);

and then in the java code (i.e. log-method)
int callId = callIdListSingleton.get(Thread.currentThread().hashCode());

Seems like good solution.

Serlvet filter is new to me. I assume it would reduce the repeated code in 
the servlets above?

ThreadLocal is something I have'nt looked into but it looks like I have a 
good reason now.

>From: "Ralph Einfeldt" <>
>Reply-To: "Tomcat Users List" <>
>To: "Tomcat Users List" <>
>Subject: RE: How to keep same thread during a session
>Date: Thu, 21 Aug 2003 16:01:09 +0200
>The threads are request based.
>Each Thread services one request at a time.
>So store the id at the start of each request in a global
>ThreadLocal or a global Hashtable with the thread as key.
>Then you can access this id from any method called in the
>lifetime of the same request.
>If you have several entry points in to your application you
>could put this in a servlet filter. (This is a good place to
>place such things anyway)
> > -----Original Message-----
> > From: Roland Nygren []
> > Sent: Thursday, August 21, 2003 3:48 PM
> > To:
> > Subject: How to keep same thread during a session
> >
> > I.e. must this CallId be used in all logging.
> > I would like to not have to pass this CallId as a parameter
> > in every method.
> > int CallId = session.getParameter("CallId");
> >, to, departureDate, returnDate,
> > numberOfPassengers,  callId);
> >
>To unsubscribe, e-mail:
>For additional commands, e-mail:

Hitta rätt köpare på MSN Köp & Sälj

View raw message