Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

virtual hosts in stand alone tomcat

 
Diego Garcia
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I have tomcat installed and i am trying to configure virtual hosts.

What i need is something like:
http://test1:8080/index.jsp for one aplication and
http://test2:8080/index.jsp for another.

Both applications are in a "web" directory outside webapps (at the same level)

This is part of my server.xml file:


Really, i can�t get it to work, can someone please assist me here?

Thanks in advance
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using one instance of Tomcat 5.5.9 to host about 6 different "sites" - your <Host name= attribute has to exactly match the way the host appears in URLs.
I also found that I had to give an absolute path for appBase.
Bill
 
Diego Garcia
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Bill for your response.

Now my Host looks like:


I changed the appBase to an absolute path, but still not working...

What do you mean exactly when you say that the name attribute has to match the host name?

Also, do i have to remove the localhost entry that comes with the initial server.xml?

Thanks again.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I left the localhost Host entry because the Engine uses that as defaultHost

The name attribute has to match the host name you use in the URL that addresses that particular host. What you would use when building a URL with the protocol/host/port constructor. So if you want people to be able to use either www.mysite.com or mysite.com, you have to have a separate Host entry for each name.

So what happens when you try to start Tomcat from a command prompt? Surely there must be some errors if it is not happy with the Host configuration.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic