Reputation: 282
I am going through one web development process in which, I have two parameters say username and password as context parameters in web.xml file like:-
<context-param>
<param-name>uname</param-name>
<param-value>demouser</param-value>
</context-param>
<context-param>
<param-name>pwd</param-name>
<param-value>demopwd</param-value>
</context-param>
One of my servlet is getting the uname and pwd field by getServletContext.getgetInitParameter("uname"); and simillarly the pwd field,
Now at some point of time, I want to change the values of context parameters through same servlet or other. How to do that. Please help me out by few suggestions.
Thanks & Regards, Ars.
Upvotes: 2
Views: 5911
Reputation: 4454
You cant modify context parameters directly, but you could use ServletContextListener
implementation to keep and modify all the necessary variables and objects. See http://docs.oracle.com/javaee/5/tutorial/doc/bnafi.html for details.
Upvotes: 2