Servlet mixing requests with multiple users.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Vincent_Smyth
Posted On:   Wednesday, May 15, 2002 07:11 AM

I have a problem with a search. How it works is,
we have a stateful session bean which executes the search, a servlet which calls this search method in the bean and a JSP to output the results.



What happens is that every now and again, the search is performing a different search as in a search performed by another user of the site.



It looks as though the servlet which simply grabs the search criteria from the request is getting confused with multiple users hitting the site and hence passing the incorrect parameters to the Session Bean. If anyone knows how to prevent this it would be greatly appreciated.

Re: Servlet mixing requests with multiple users.

Posted By:   jason_eastwood  
Posted On:   Wednesday, May 15, 2002 07:23 AM

Be careful to synchronize access to any shared resources, including your servlets class and instance variables - your servlet is probably running in a multithreaded servlet container that handles multiple threads at the same time ( each user uses a new thread )

I would suggest avoiding instance or class variables alltogether and pass local variables through your servlets. Its faster than having to synchronize portions of your code.
About | Sitemap | Contact