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
HttpServletRequest request;
...
ServletContext context = request.getSession().getServletContext();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.