• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

context-param

 
dolly shah
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following are true regarding the parameters defined using the <context-param> element of a deployment descriptor?

Options

Select 2 correct options.


They are thread safe.-answer


They are accessible from multiple threads simultaneously and from any servlet of the web application.-answer


They can be modified using the setAttribute() method.


They can be modified using the setParameter() method.


They can be modified using the setInitParameter() method.


Detailed Explanation

<context-param> element is used to define the initialization parameters for the web application as a whole. They are read only and are thus thread safe. You cannot add or modify the parameters using any of the set methods.

--------------------------------
-This example is from jdiscuss.com. I have posted example & also answers & explaination. But I don't understand why you cannot add or modify the parameters using any of the set methods. I saw the ServletContext interface has a setAttribute(). Can anyone clear my doubt?
 
maih fhil
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
context parameter and attribute are two different things
The former stores just the name/value String pairs whereas the latter stores name and Object pairs
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic