• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Adding DOS system properties variables to server.xml

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic