I have to set initialization parameters based on environment to a servlet, NOT via web.xml but via code,
but my servlet version is not 3.0 , so I cannot use this
http://docs.oracle.com/javaee/6/api/javax/servlet/ServletContext.html#setInitParameter%28java.lang.String,%20java.lang.String%29
I dont have access to the servlet code so I am writing a new servlet that extends it and I want to add initialization parameters via java code ..Any suggestions?
abc
abc
abc
localhost:2001
1
Is there a way to do the above thing(adding init-params) by extending servlet abc and setting attributes to the servlet config (overriding init())?
解决方案
I overrode the method getInitParameter of GenericServlet and I was able to solve my problem..
@Override
public String getInitParameter(String name) {
//Get initparams here
return "MyInitParams";
}