Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing a system property to tomcat

 
siva raju
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic