Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

context param

 
muthu moorthy
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any body can tell me ?

getServletContext().setAttribute("foo", "22");

This will update DD's <context-param>, param-name and param-value right ?

Thank you.
 
Sayak Banerjee
Ranch Hand
Posts: 292
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getServletContext().setAttribute("foo", "22");

This will update DD's <context-param>, param-name and param-value right ?


<context-param> element is for context init parameters(not attributes)....you cannot set an init parameter programmatically.....go through parameters and attributes once again
 
Stary Kapec
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No!

Context-params are deploy-time constants. They are read only. You can read them by getServletContext().getInitParam("param-name")

getServletContext().setAttribute("foo", "22"); - This invocation sets an attribute named foo in the application scope.

Attributes and context-params are different concepts.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Attributes are not parameters. Say that 100 times before you sleep today

Also init params and context params are read only
 
muthu moorthy
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you guys.

Thought i remembered init param & context param are deploy time constants and cannot be updated, some where i did see this code below, i got confused.

Could you please explain about attributes giving an scenerio. Attributed belongs to session object ?
 
muthu moorthy
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you guys.

Though i remembered init param & context param are deploy time constants and cannot be updated, some where i did see this code below, i got confused.

Could you please explain about attributes by giving an scenerio. Attributes belong to session object ?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic