File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple threads of a servlet instance and servletConfig

 
ganga rk
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Each servlet has a unique servletConfig.
Does multiple threads of a given servlet instance share the same servletConfig object ?
Please respond....
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know. Doesn't matter. Since one only reads from the ServletConfig, and never writes to it, there are no multi-threading issues.
 
M Nadeem
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right answer. ServletConfig is read only object. All of its properties are set by JSP/Servlet container. Access of multipal threads have no harm to Servlet Config.
 
ganga rk
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So when we have a situation like this:
" Many requests are coming in for a given sevlet A.
So the container would create threads of that servlet(A) for each request.
Now each of this thread would have a servlet config."

Now, would all the threads be having the same servlet config i.e will the container create only one servlet config for a servlet instance(for A in our case)and pass its copy to its threads?
Or will it create a servlet config for each of the thread?
 
amit punekar
Ranch Hand
Posts: 544
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
There is only one instance of the servlet and hence one instance of ServletConfig.
The threads that process the requests call the service() method of the Servlet which has one single instance.
The thread and the instance are two separate thing.
Hope this help you to clarify your understanding about the same.

Regards,
Amit
 
bala rimmalapudi
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, Every servlet will have only one ServletConfig, and the same ServletConfig will be used by multiple threads of that specific Servlet.
 
Kumar Raja
Ranch Hand
Posts: 547
2
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Point to be noted here is one servlet per jvm..
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic