This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Adding DOS system properties variables to server.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Adding DOS system properties variables to server.xml" Watch "Adding DOS system properties variables to server.xml" New topic
Author

Adding DOS system properties variables to server.xml

Bill Farago
Greenhorn

Joined: Dec 16, 2011
Posts: 2
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

Joined: Jun 25, 2001
Posts: 15952
    
  19

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Bill Farago
Greenhorn

Joined: Dec 16, 2011
Posts: 2
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

Joined: Jun 25, 2001
Posts: 15952
    
  19

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding DOS system properties variables to server.xml
 
Similar Threads
cant compile
Tomcat Setup
error while working with tomcat
Deploying Servlets on tomcat
tomcat4 installation....please help