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.
After some hit and trial, placed name=rickesh in catalina.properties present in C:\apache-tomcat-6.0.35\conf. Works fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With