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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With