3

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.

Mono Jamoon
  • 4,437
  • 17
  • 42
  • 64

1 Answers1

8

After some hit and trial, placed name=rickesh in catalina.properties present in C:\apache-tomcat-6.0.35\conf. Works fine.

Mono Jamoon
  • 4,437
  • 17
  • 42
  • 64