You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Roggeveen, Brian P" <br...@eds.com> on 2003/08/01 01:53:02 UTC

Threading Question

Hello,

I was wondering if it is safe to assume that when using the multithreaded
model, a single unique thread will handle each incoming request? In other
words, does the servlet container implement a thread per connection model or
is there a way to specify this configuration? 

The reason I ask is that at any given point within my servlets' supporting
code/beans, I would like to have access to the HttpSession instance that
corresponds to the client for whom the current line of code is being
executed. Another way of looking at the situation would be at any given
point within my servlets' supporting code/beans, I would like to have access
to the HttpRequest that caused this particular line of code to be executed.
In order to accomplish this, I envisioned using a Map that contained thread
keys and HttpSession values. As requests came in, the Map would be updated
appropriately such that supporting code need only look up an HttpSession
using the current thread. Maybe I'm making this more complex than it needs
to be.

Thanks!
Brian Roggeveen
EDS - Work Force Management
Voice: (314) 264-8991
Fax:    (314) 264-8901
Email: brian.roggeveen@eds.com


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Threading Question

Posted by Bill Barker <wb...@wilshire.com>.
"Roggeveen, Brian P" <br...@eds.com> wrote in message
news:F85E99B28A65D411A6BC00508BE3242C143E8FD0@USPLM204.txpln.us.eds.com...
> Hello,
>
> I was wondering if it is safe to assume that when using the multithreaded
> model, a single unique thread will handle each incoming request? In other
> words, does the servlet container implement a thread per connection model
or
> is there a way to specify this configuration?

The thread-per-connection model is mandated in the Servlet spec, so Tomcat
(and any other compliant Servlet-Container) will behave this way.

>
> The reason I ask is that at any given point within my servlets' supporting
> code/beans, I would like to have access to the HttpSession instance that
> corresponds to the client for whom the current line of code is being
> executed. Another way of looking at the situation would be at any given
> point within my servlets' supporting code/beans, I would like to have
access
> to the HttpRequest that caused this particular line of code to be
executed.
> In order to accomplish this, I envisioned using a Map that contained
thread
> keys and HttpSession values. As requests came in, the Map would be updated
> appropriately such that supporting code need only look up an HttpSession
> using the current thread. Maybe I'm making this more complex than it needs
> to be.

You are most definitely making this more complex than it needs to be ;-).

>
> Thanks!
> Brian Roggeveen
> EDS - Work Force Management
> Voice: (314) 264-8991
> Fax:    (314) 264-8901
> Email: brian.roggeveen@eds.com




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Threading Question

Posted by Bill Barker <wb...@wilshire.com>.
"Roggeveen, Brian P" <br...@eds.com> wrote in message
news:F85E99B28A65D411A6BC00508BE3242C143E8FD0@USPLM204.txpln.us.eds.com...
> Hello,
>
> I was wondering if it is safe to assume that when using the multithreaded
> model, a single unique thread will handle each incoming request? In other
> words, does the servlet container implement a thread per connection model
or
> is there a way to specify this configuration?

The thread-per-connection model is mandated in the Servlet spec, so Tomcat
(and any other compliant Servlet-Container) will behave this way.

>
> The reason I ask is that at any given point within my servlets' supporting
> code/beans, I would like to have access to the HttpSession instance that
> corresponds to the client for whom the current line of code is being
> executed. Another way of looking at the situation would be at any given
> point within my servlets' supporting code/beans, I would like to have
access
> to the HttpRequest that caused this particular line of code to be
executed.
> In order to accomplish this, I envisioned using a Map that contained
thread
> keys and HttpSession values. As requests came in, the Map would be updated
> appropriately such that supporting code need only look up an HttpSession
> using the current thread. Maybe I'm making this more complex than it needs
> to be.

You are most definitely making this more complex than it needs to be ;-).

>
> Thanks!
> Brian Roggeveen
> EDS - Work Force Management
> Voice: (314) 264-8991
> Fax:    (314) 264-8901
> Email: brian.roggeveen@eds.com




RE: Threading Question

Posted by mike jackson <mj...@cdi-hq.com>.
You could do something like that, or you could just have the servlet pass
that into the supporting code/beans.  It'd be a lot cleaner and clearer
design wise to just pass the information, either encapsulated into a new
object or just the values you need.

--mikej
-=------
mike jackson
mjackson@cdi-hq.com

> -----Original Message-----
> From: Roggeveen, Brian P [mailto:brian.roggeveen@eds.com]
> Sent: Thursday, July 31, 2003 3:53 PM
> To: 'tomcat-user@jakarta.apache.org'
> Subject: Threading Question
> 
> Hello,
> 
> I was wondering if it is safe to assume that when using the multithreaded
> model, a single unique thread will handle each incoming request? In other
> words, does the servlet container implement a thread per connection model
> or
> is there a way to specify this configuration?
> 
> The reason I ask is that at any given point within my servlets' supporting
> code/beans, I would like to have access to the HttpSession instance that
> corresponds to the client for whom the current line of code is being
> executed. Another way of looking at the situation would be at any given
> point within my servlets' supporting code/beans, I would like to have
> access
> to the HttpRequest that caused this particular line of code to be
executed.
> In order to accomplish this, I envisioned using a Map that contained
> thread
> keys and HttpSession values. As requests came in, the Map would be updated
> appropriately such that supporting code need only look up an HttpSession
> using the current thread. Maybe I'm making this more complex than it needs
> to be.
> 
> Thanks!
> Brian Roggeveen
> EDS - Work Force Management
> Voice: (314) 264-8991
> Fax:    (314) 264-8901
> Email: brian.roggeveen@eds.com
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org