File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Context Parameters - Thread safe? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Context Parameters - Thread safe?" Watch "Context Parameters - Thread safe?" New topic

Context Parameters - Thread safe?

Rashmi Gupta

Joined: Jul 27, 2007
Posts: 2

The question below is from Java Beat Mock Exam.

26.Which of the following are true regarding the parameters defined using the <context-param> element of a deployment descriptor?

Select 2 correct options.
A.They are thread safe.
B.They are accessible from multiple threads simultaneously and from any servlet of the web application.
C.They can be modified using the setAttribute() method.
D.They can be modified using the setParameter() method.
E.They can be modified using the setInitParameter() method.


I think option A is incorrect, as the context parameters are never thread safe.
Any thoughts on this problem would be appreciated.

Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
Context parameters are read only and therefore are thread safe. These parameters (as well as Servlet init parameters) are set in the web.xml.

Context attributes, on the other hand are not thread safe.

I think you are confusing parameters and attributes.
Rashmi Gupta

Joined: Jul 27, 2007
Posts: 2
Thanks for the response Michael. I got the difference.
I agree. Here's the link:
subject: Context Parameters - Thread safe?
It's not a secret anymore!