This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding DOS system properties variables to server.xml

 
Bill Farago
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Tomcat 7, using Java 1.6 on a Windows XP platform, and I'm trying to populate some fields in the server.xml file with the DOS environment variables COMPUTERNAME and USERDOMAIN concatenated with a ".". This will provide a unique name of "COMPUTERNAME.USERDOMAIN". I've not been successful yet of with either passing the values in with a -Dxxxx=yyyy from the Tomcat / Java tab on the administration panel, or with figuring out how to specify anything other than system properties (like ${user.home}).

Got any ideas. Thanks in advance!

-- Bill
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't remember if Tomcat's server.xml file resolves ${variable} expressions or not. Since each Tomcat instance of a multi-instance server requires a separate CATALINA_HOME, which in turn contains a separate conf/server.xml. the benefits of variable substitution aren't as great as they would be for other situations.

However, try this:

1. Create a file named bin/setenv.bat in your CATALINA_HOME directory.

2. Put this line in it:



You can also put any standard config options such as the -xMx option on that assignment statement.

3. Start Tomcat and see if server.xml makes the desired substitutions.
 
Bill Farago
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The forum at:

http://old.nabble.com/$%7Buser.home%7D-and-other-server.xml-tags-accepted-by-Tomcat--td19710754.html

has an excellent discussion about environment variables, and says that any of the Java System.Properties that Java can read, the server.xml file can access also. However, the DOS system properties -- like I mentioned before -- are more challenging and are not directly accessible by the server.xml file. I only have one server (well, a backup server as well), and the host computer name and network name are used to identify the location of a resource. The server functionality is being ported over from a Sun Server to Tomcat. The SunServer has a method for obtaining those values I'm looking for, but Tomcat doesn't seem to have that.

I have tried that format -- ${user.home} I mentioned in my OP in the server.xml file and it works, but its not the information I'm looking for.

I'll work with your suggestion and see what happens. Thanks.

-- Bill
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did forget one thing. If you want Windows environment variables, the format is:


That will do the appropriate substitution, just as it would in any other ".BAT" file.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic