I am trying to set a system property and retrieve it in my Servlet.
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println(System.getProperty("name"));
}
I placed this: -Dname=rickesh
in CATALINA_OPTS but running the code returns null
. I have no idea as to how I can pass parameters to Tomcat at runtime and use it via System.getProperty(String)
. A Google Search to do the same suggests to do a JNDI or set in CATALINA_OPTS, but no example on how to set either.
Please advice.