• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Get the virtual host name from the tomcat server.xml using java  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In the Tomcat server.xml there are multiple host(virtual host),so now using java code i need get all the Host in arraylist.
I am unable to find out the proper solutions.Is there any that can help me out?
 
Ranch Hand
Posts: 1067
2
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first thing which comes to mind is reading the file, and parsing out what you want.
 
Sunny Bhinde
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Willam,
I need to get host name let take an example:
if there are 3 virtual host in the server.xml i.e
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
</Host>
<Host name="abc.com" appBase="webapps" unpackWARs="true" autoDeploy="true">
</Host>
<Host name="xyz.com" appBase="webapps" unpackWARs="true" autoDeploy="true">
</Host>

so now i need array contains the host name i.e {"localhost","abc.com ","xyz.com"}

I hope you got
 
Bartender
Posts: 19962
95
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Getting the virtual host names as a general collection from the Tomcat server.xml file is relatively straightforward. You can do anything from a mindless "grep" to a full-blown XSLT or Digester app.

Getting the virtual host names that a single webapp is running under from inside the webapp is quite a different story.

Most Tomcat users think of webapps in terms of exploded WAR files, so there's one instance of the WAR directory for each deployed instance of that webapp. However, that's a Tomcat quirk. You can (and I routinely do) deploy a WAR in the strict J2EE sense of an actual WAR file. For example, I can deploy the file "/opt/javaranch/webapps/forum.war" as many times as I want into as many hosts as I want under as many Contexts as I want in as many Tomcat instances as I want (allowing for hardware limitations). There's absolutely no way that the webapp itself can enumerate all the virtualhost names that it is running under - especially in cases where there are several different Tomcat JVMs using it.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!