tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Ruthenbeck <just...@nextengine.com>
Subject Re: How to keep a single user session from having multiple threads?
Date Fri, 20 Aug 2004 02:03:57 GMT

I'll answer your specific question, but first let me say: In the 
situation you are describing here, the root problem is not that the same 
JSP is being run concurrently for a particular session -- it's that your 
application has been designed such that you care.  Mainstream jsp/servlet 
applications should be coded in a thread-safe manner such that data 
protection, locking, etc is provided in an appropriate way outside your 
jsp/servlet.

Now, to answer your question:

You cannot configure Tomcat to limit a session to one thread.  What you 
really need to do is limit a single client (in a given session) from 
making two requests to the same JSP.  Code your client this way, then add 
logic (in a filter, I'd suggest) to enforce the restriction.  Doing this 
will work, but you'll find that you're swimming upstream against the 
spirit of the servlet spec, so keep that in mind.

If your only concern is one of resource usage (that's what your email 
seems to imply), then you'd be better off trying to find out why your 
clients are making two simultaneous requests or (if it's a configuration 
problem), why you've got Tomcat configured to make that happen.  If you 
want help with that, feel free to reply with more info to the list.

Good luck!
justin


At 06:04 PM 8/19/2004, you wrote:
>Hello folks,
>I have a situation in which 2 threads are being started in the same user
>session.
>Now, that in itelf is not necessarily a problem - the problem it that both
>threads are executing the same JSP pages.
>This still does not hurt anything as yet,(The JSPs use session variables 
>so
>that different users don't interfere with each other)
>but in the logs (using log4j) I can see the same JSP being executed by
>multiple threads simultaneously.
>
>There is definitely no need for this.
>I'd like to configure Tomcat such that it only runs one JSP at a time per
>user session.
>However, I am fine with having each user session start its own thread.
>Can this be configured in Tomcat (one session = one thread) or is this
>outside of Tomcat?
>
>Here is an example - notice the interleaving of the threads, as they 
>execute
>the same JSP (ClothingBuyer.jsp)
>such that Thread 10 finishes while Thread 8 is still in the middle of
>working,
>and remember, these are from one user session - not two users.
>[Thread-10]2004-08-19 11:16:01,494 DEBUG FitMe.site.ClothingBuyer  -
>Self=user1
>[Thread-10]2004-08-19 11:16:01,494 DEBUG FitMe.site.ClothingBuyer  - 
>Result
>from query is not null, continuing
>[Thread-10]2004-08-19 11:16:01,508 DEBUG FitMe.site.ClothingBuyer  - A 
>user
>name found: user2
>[Thread-8]2004-08-19 11:16:01,516 DEBUG FitMe.site.ClothingBuyer  -
>Self=user1
>[Thread-8]2004-08-19 11:16:01,516 DEBUG FitMe.site.ClothingBuyer  - Result
>from query is not null, continuing
>[Thread-10]2004-08-19 11:16:01,519 DEBUG FitMe.site.ClothingBuyer  - A 
>user
>name found: userx
>[Thread-8]2004-08-19 11:16:01,529 DEBUG FitMe.site.ClothingBuyer  - A user
>name found: user2
>[Thread-10]2004-08-19 11:16:01,530 DEBUG FitMe.site.ClothingBuyer  - A 
>user
>name found: user3
>[Thread-10]2004-08-19 11:16:01,537 DEBUG FitMe.site.ClothingBuyer  - A 
>user
>name found: user4
>[Thread-10]2004-08-19 11:16:01,539 DEBUG FitMe.site.ClothingBuyer  -
>Finished with user list.
>[Thread-8]2004-08-19 11:16:01,544 DEBUG FitMe.site.ClothingBuyer  - A user
>name found: userx
>[Thread-8]2004-08-19 11:16:01,550 DEBUG FitMe.site.ClothingBuyer  - A user
>name found: user3
>[Thread-8]2004-08-19 11:16:01,556 DEBUG FitMe.site.ClothingBuyer  - A user
>name found: user4
>[Thread-8]2004-08-19 11:16:01,557 DEBUG FitMe.site.ClothingBuyer  - 
>Finished
>with user list.
>
>Once again, here is my goal:
>I'd like to configure Tomcat such that it only runs one JSP at a time per
>user session.
>I am fine with having each user session start its own thread.
>Can this be configured in Tomcat (one session = one thread) or is this
>outside of Tomcat?
>
>Bill Bruns
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


______________________________________________
Justin Ruthenbeck
Lead Software Engineer, NextEngine Inc.
justinr - AT - nextengine DOT com
Confidential. See:
http://www.nextengine.com/confidentiality.php
______________________________________________


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


Mime
View raw message