This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamic Setting of Server Port in Tomcat

 
Jeffies Shah
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Is it possible to set Tomcat port dynamically from a text file or a properties file? If so, how to achieve that?

Thanks and regards,
Jaffer.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ports Tomcat uses are set on startup from the server.xml file, if you want to change ports you have to restart Tomcat.
Why would you want to change ports dynamically? You can have multiple instances of Tomcat running on the same machine if you assign them different ports.

Bill
 
Kalpesh Patel
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As William said, you can use multiple tomcat installed and one of them can work as load balancer. You can use module JK connector for this purpose.
 
Jeffies Shah
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks William and Kalpesh!

Actually, I want to start Tomcat using a script. Before starting tomcat in a port, I want to check whether someother application or someother tomcat itself is running on that port. If some application is running on that port, I can start Tomcat in a different free port.

So, is there a way to dynamically set Tomcat port, before starting it?

Thanks and regards,
Jaffer.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I said already, Tomcat sets ports based on the contents of server.xml - you could certainly re-write server.xml with revised port numbers before starting Tomcat.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic