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" <[EMAIL PROTECTED]>
Reply-To: "Tomcat Users List" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
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:[EMAIL PROTECTED]
> Sent: Thursday, August 21, 2003 3:48 PM
> To: [EMAIL PROTECTED]
> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


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


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to