tomcat-users mailing list archives

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

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

>From: "Ralph Einfeldt" <ralph.einfeldt@uptime-isc.de>
>Reply-To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
>To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
>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 [mailto:roland_nygren@msn.com]
> > Sent: Thursday, August 21, 2003 3:48 PM
> > To: tomcat-user@jakarta.apache.org
> > 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");
> > fareFinder.search(from, to, departureDate, returnDate,
> > numberOfPassengers,  callId);
> >
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>

_________________________________________________________________
Hitta rätt köpare på MSN Köp & Sälj http://www.msn.se/koposalj


Mime
View raw message