File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes tomcat 4.1 system property setup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "tomcat 4.1 system property setup" Watch "tomcat 4.1 system property setup" New topic

tomcat 4.1 system property setup

Rajesh Navduri
Ranch Hand

Joined: Jun 28, 2001
Posts: 31

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
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.

James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
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

Joined: Dec 11, 2004
Posts: 13410

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.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: tomcat 4.1 system property setup
It's not a secret anymore!