File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Can we do this Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Can we do this" Watch "Can we do this" New topic

Can we do this

Arpit Gadle
Ranch Hand

Joined: Dec 16, 2008
Posts: 69

I hope this is the right place to post this question.

I have small applications running locally on my system

1. http://localhost:8080/firstapp
2. http://localhost:8080/secondapp
3. http://localhost:8080/thirdapp

What I want is

instead of using http://localhost:8080/somewebapp to run a webapplication

can i run it as



Lalit Mehra
Ranch Hand

Joined: Jun 08, 2010
Posts: 384

please post servlet related posts only in servlet forum
Rob Spoor

Joined: Oct 27, 2005
Posts: 20271

Agreed. I'll move it there.

Note that, and require three domains. Perhaps you can better switch it around:, and You only need to register and turn the others into sub domains.

After that perhaps Apache's HTTPD server with mod_proxy or URL rewriting can help you out. I don't know the exact details, but you can find more information on Tomcat's website. In short, you put an Apache HTTPD server on port 80 in front of Tomcat. The requests go to this HTTPD server which forwards the requests (completely transparently) to Tomcat, which handles them and sends the responses through HTTPD back to the user.

How To Ask Questions How To Answer Questions
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

the easy way to do this locally is to map the domains to the loopback IP in your hosts file

Then all requests to will result in the request being sent to your local machine.
Next step is to configure the Tomcat container so that requests to the host get sent to the correct web app, which you do by adding a virtual host to tomcat

Yes, Rob's is the better solution for live systems. My answer above is what I do when i want to simulate multiple domains locally
I agree. Here's the link:
subject: Can we do this
It's not a secret anymore!