This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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
 
Consider Paul's rocket mass heater.
 
subject: passing a system property to tomcat
 
Similar Threads
error in executing the jsp
Error ##### org.hibernate.exception.GenericJDBCException: Cannot open connection
Struts, DBCP weird problem
Why does getCodeBase return null?
How to write to a Property file at Run time residing in the WEB-INF