• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Which among the servlet objects are synchronized

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Among the servlet objects, like request, response, session, ServletContext, ServletConfig etc. which are synchronized?
 
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 56
Eclipse IDE Postgres Database Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I’m tired of walking, and will rest for a minute and grow some wheels. This is the promise of this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic