aspose file tools*
The moose likes Tomcat and the fly likes passing a system property to tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "passing a system property to tomcat" Watch "passing a system property to tomcat" New topic
Author

passing a system property to tomcat

siva raju
Ranch Hand

Joined: Oct 10, 2003
Posts: 37
My code uses System.getProperty() in a .war file. How do I pass a property to the tomcat server. I dont want to use the -D option while starting the server.


Siva<br />-----<br />SCWCD 1.4, SCJP 1.4, SCBCD(Preparing), CCNA
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

you will have to use some archane majik.

Seriously.

If your code uses System.getProperty(), you have little choice but to pass in that property with a -D switch.

There is a possibility to use System.setProperty() method, but ask yourself: "If I know what value to set *into* the system, why do I need to get it *from* the system?"
siva raju
Ranch Hand

Joined: Oct 10, 2003
Posts: 37
Actually, I was thinking on these lines,

Does the tomcat server has some file in which we can set our startup -D options instead of in the command line? I know this to be true in some other server(i just cant remember its name).

Or is there any option within the deployment descriptor of the war which lets us do this.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

yes, just check the bin directory for the startup scripts. They already pass a few -d parameters.

The parameters you'd be able to set in web.xml are retrieved through the servlet API's, not the java.lang.System API
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: passing a system property to tomcat