File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

Can we do this

Arpit Gadle
Ranch Hand

Joined: Dec 16, 2008
Posts: 69

Hi...
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

something.firstapp.com
something.secondapp.com
something.thirdapp.com

locally


Regards,
Arpit


Lalit Mehra
Ranch Hand

Joined: Jun 08, 2010
Posts: 384

please post servlet related posts only in servlet forum


http://plainoldjavaobject.blogspot.in
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19790
    
  20

Agreed. I'll move it there.

Note that something.firstapp.com, something.secondapp.com and something.thirdapp.com require three domains. Perhaps you can better switch it around: firstapp.something.com, secondapp.something.com and thirdapp.something.com. You only need to register something.com 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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
David O'Meara
Rancher

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

127.0.0.1 yourapp.something.com

Then all requests to yourapp.something.com will result in the request being sent to your local machine.
Next step is to configure the Tomcat container so that requests to the yourapp.something.com 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
 
 
subject: Can we do this