Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet Context  RSS feed

 
Priya Sri
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,

I got a doubt that if we set attributes through servlet Context object, will they get stored in <context-param> tag of web.xml file?

bye..
Priya
 
David Ulicny
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's the other way around, you set your init-params in web.xml and they will be available to your context.

For an example go to http://simple.souther.us and grab Simple Context Init Params.

Also look at Simple Servlet Init Params.
 
Rohit Bhagwat
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Priya

U cant set the Parameters in web.xml file

These parameters are read only.

However you do have a ServletContext object which has setAttribute method that set the attribute in servletcontext and is avaliable to your webapp till your container is alive. Means till you dont shutdown the container.

Hope your doubt is solved\

Regards
Rohit.
 
Preetham Chandrasekhar
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IN WEB.XML you store the parameters and using servelt context in the app you store attributes...the parameters from the web.xml are read-only and are loaded when the application loads for the first time.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!