0

My project is using some very old code and I can't really update it. There are some values that I would like to access in WEB-IN/web.xml/context-param. In recent version of java you could use :

HttpServletRequest servlet;
...
String myParam = servlet.getServletContext().getInitParameter("myParam");

But the method getServletContext() doesn't exist in my project configuration.

Is there another way to gain access to the WEB-INF/web.xml/context-param for old version of java/tomcat?


Tomcat Version : Apache Tomcat/6.0.37
Servlet Specification Version : 2.5
JSP version : 2.1

According to this post, it was introduced in Servlet 3.0

Community
  • 1
  • 1
Gudradain
  • 4,653
  • 2
  • 31
  • 40

1 Answers1

1
HttpServletRequest request;
...    
ServletContext context = request.getSession().getServletContext();
Gudradain
  • 4,653
  • 2
  • 31
  • 40
  • Or, if you have a Filter or Servlet, you can also get it from there (without starting a session) – Thilo Jul 02 '14 at 23:55