File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes <context-param> - read only? 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-param> - read only?" Watch "<context-param> - read only?" New topic
Author

<context-param> - read only?

Paul Statham
Ranch Hand

Joined: Dec 05, 2008
Posts: 40
Ok I've come across a question which says context params are thread safe because they are read only so for example.



We can read that by doing



But there is also a setInitParam



So how can it be thread safe? It's clearly not read only?
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1529
    
  22

Hi Paul,

Don't forget that you are doing questions from the SCWCD 5 exams that covers the EE1.4 specs, and the new exam covers EE6...

This method setInitParameter(java.lang.String name, java.lang.String value) is introduced in EE6...

Context params were thread safe in the EE1.4 and EE5, but now that is not the case anymore...

Regards,
Frits
Paul Statham
Ranch Hand

Joined: Dec 05, 2008
Posts: 40
Actually this is a question from enthuware's 1Z0-894 set of questions. So I'm guessing the answer they've given is wrong?
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1529
    
  22

Actually this is a question from enthuware's 1Z0-894 set of questions. So I'm guessing the answer they've given is wrong?


Ok, enthuware doesn't make many mistakes, if I just read the API :
true if the context initialization parameter with the given name and value was set successfully on this ServletContext, and false if it was not set because this ServletContext already contains a context initialization parameter with a matching name

It looks like it is still thread safe. Just check the Servlet3.0 specs (I can't get to it from here) and search for Threading Issues to verify whether this is still the case.

Regards,
Frits
Stoian Azarov
Ranch Hand

Joined: Jun 01, 2011
Posts: 113
Hello guys,
Good catch!!! I haven't noticed this line from the API documentation. It is good to know that it is impossible to set new value on already set context parameter.
Cheers
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: <context-param> - read only?
 
Similar Threads
Sybex: Context attribute thread safety
Warning. Sybex book. p.285-286. Fundamentals error.
Are context-parameters thread-safe?
-D option like when start a simple Java with init params
How to disallow directory browsing on web server