tags:

views:

80

answers:

4

I have a web application "quicker" deployed in Tomcat5.5 version. Usually, I run this application by using url, localhost/quicker and it loads the index.jsp file which is the home page of application. I would like same application to be run using url, www.local.dev.mydomain.com/quicker. Would it be possible by doing some configuration in server.xml or some other place? One way of doing this is could be, modify hosts file in windows as -

#   127.0.0.1  localhost
     127.0.0.1 www.local.dev.mydomain.com

But, I want to this in tomcat manner if possible.

A: 

Just omit the host name from all URLs (i.e. use /quicker instead of http://www.local.dev.mydomain.com/quicker). That way, all your links will be local to the web server the app runs on, no matter which domain that is.

Aaron Digulla
A: 

In the server.xml there is the Host element, which you can use to define one or more virtual hosts handled by Tomcat. However, there is no way to do what you want with only Tomcat configuration.

A DNS must be intervene somewhere to route all requests targeted to a domain name to the appropriate IP address. The hosts file performs a simple form of DNS functionality.

kgiannakakis
A: 

You need to setup an entry in DNS to point www.local.dev.mydomain.com to the machine. You can add the entry to hosts file but you have to do that on the client, where browser is running.

Once you do that, just make sure you have something like this in your server.xml,

<Engine defaultHost="localhost" name="Catalina">

All undefined hostname will be pointed to defaultHost, which is your localhost.

ZZ Coder
A: 

When you point your browser to the URL of the webapp, it's the browser that needs to translate that host name to the IP address of your tomcat server. This has nothing to do with tomcat (atleast not unless you also want virtual hosts).

So one way is indeed to just modify the hosts file, that will only work on your local machine naturally. For other users you need to update the dns server they're using with the info for your tomcat server.

nos