Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

tomcat 4.1 system property setup

 
Rajesh Navduri
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have to read a system property from the tomcat 4.1. I have made the following changes..

1. In my catalina.bat after this line
set CATALINA_OPTS=%CATALINA_OPTS% -Dsun.io.useCanonCaches=false
I have addded -DEnv=dev
2. In my java file
String env = System.getProperty("Env");

But I am getting this env field as null.

Can someone suggest me how to get the system properties from tomcat.

Cheers
Rajesh
 
James Ellis
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure why you'd want to set a system property in the catalina.bat file. If you want to set a variable for the web application to use you can set a ServletContext init-param up by putting the following in web.xml



Then when you want to reference the parameter you can get it from within a servlet like this:

 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to be able to retrieve it with System.getProperty, set it under JAVA_OPTS not CATALINA_OPTS.

Unless you have a specific reason for setting it at the JVM level though, you should follow James' advice and use either context init params or servlet init params.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic