Reputation: 2178
Is there a way to add a context-param programmatically? I don't want to add in the web-xml. Specifically I want to do what the answer in this post suggests: Invoking methods with parameters by EL in JSF 1.2.
Upvotes: 2
Views: 5142
Reputation: 9178
Yes it is possible.
In the servlet's init method, use
getServletConfig().getServletContext().setInitParameter("[Parameter name]", "[value]");
OR simply
getServletContext().setInitParameter("[Parameter name]", "[value]");
This must do the trick for you.
For the application load,
In web.xml, when you declare this servlet, provide <load-on-startpup>
element as 1 for this servlet.
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>TestServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
Upvotes: 9