If I had to define a context-visib parameter at runtime, I wouldn't use ServletContext.setInitParameter()
because init parameters are defined in the deployment descriptor once for all, and I suppose that ServletContext().setAttribute()
would be more appropriate.
Said that,
- is my approach correct? In which case should I use
ServletContext.setInitParameter()
instead ofServletContext().setAttribute()
? - why is the method called
setInitParameter()
? Init parameters are actually defined forServletConfig
in the web.xml file, I'm setting/getting context parameters (owning toServletContext
) instead.