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

Which among the servlet objects are synchronized

 
Ananda Sen
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Among the servlet objects, like request, response, session, ServletContext, ServletConfig etc. which are synchronized?
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ananda Sen wrote:Among the servlet objects, like request, response, session, ServletContext, ServletConfig etc. which are synchronized?


i didn't understand your question. are you talking about the paramerters , variables etc currently held by these objects ???

avi sinha
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Objects are not synchronized - code is. You can generally find information about what is and isn't synchronized (or what is or isn't thread-safe to do) in the javadocs of a class.

Note that web apps are not thread-safe unless you make them so in your code.
 
Charles 'King
Ranch Hand
Posts: 56
Eclipse IDE Postgres Database Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ananda Sen wrote:Among the servlet objects, like request, response, session, ServletContext, ServletConfig etc. which are synchronized?


As stated above look at the api docs.

Here's an example on how to make ServletContext attributes thread safe. You must lock your ServletContext if you want to guarantee thread safety:


 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thread safe attributes or variables :

1> local variables within the service methods
2> request attributes

3> request parameters
4> servlet or context init-params etc

actually everything which can't be changed in a program are thread safe . 3 and 4 are just examples which i have added as they are frequently asked in mock exams.



avi sinha
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic