Jump to content
Excelsior Forums

Changing Tomcat Window title to include IP Address?

Recommended Posts

My Tomcat 7.0.55 app runs on my customer's Windows machines on a private local area network.  I use the latest ExcelsiorJet and Excelsior Installer to create the setup.exe.

When my server runs, the "Tomcat" command window and title is shown.  I would like to configure the window title to instead be "MY SERVER - 192.168.1.x".  I've read that catalina.bat will look for a TITLE environment variable but don't know how well that plays with ExcelsiorJet.


Can you recommend that best way to replace the "Tomcat" window title to include ...

1) My application server's name.  Using my application icon was a helpful first step - users see my icon next to "Tomcat", which they know nothing about.

2) The IP address of my Tomcat server on the per-customer LAN.  This is more important than #1 because each customer has his own LAN where computers are running my server and browsers.  I currently have to explain how to run ipconfig.exe on the server and to use that address in their browsers, but this is a bit "too much" for my customers.  (While changing their WiFi router's configuration to static IP addresses would help, this is beyond what I can expect of my customers).

If the Tomcat window had its IP address, I can then easily ask my customers to use that address in their browsers.  If you have any alternate suggestions, I am open to those as well.  In my servlet's startup, I've tried to dynamically create an HTML page containing the IP address and the calling java.awt.Desktop.browse, but I think not having a JVM available prevents that from working.


Thanks in advance,


Share this post

Link to post
Share on other sites

SOLVED.  Here's the email I got from @xappymah ...



You can set TITLE environment variable to change the window title in the same way as if you run tomcat on Oracle JRE as long as the Tomcat server is started with "startup.bat".


For example, you can create another batch-script "bin-native/startup-wrap.bat" (note that this script shoud be created in "bin-native" directory after the compilation of your app) where you can set TITLE environment variable and run the original startup.bat:


---- startup-wrap.bat ----

set SCRIPTS_DIR=%~dp0

set TITLE=Your custom title

call "%SCRIPTS_DIR%\startup.bat"



Then you can configure shortcuts in JetPackII to run this script instead of "startup.bat".


So, if you can get the IP address via a batch script then this solution should work.


I then created the following p1ts-startup.bat file which is called in my JetPackII shortcuts.  The http://stackoverflow.com/questions/5898763/how-do-i-get-the-ip-address-into-a-batch-file-variable thread was useful for obtaining the IP address via ping.exe.

@echo off
rem Place in Tomcat\bin-native adjacent to startup.bat
for /f "delims=[] tokens=2" %%a in ('ping -4 -n 1 %ComputerName%^|findstr [') do set TITLE=P1TS Server %%a
call startup.bat


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now