• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

how to map www.test.com to http://localhost:8080/test/index.jsp on Tomcat server

 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can i give a url say www.test.com, so that my j2ee app runs on tomcat server.
Is thr any way that i can map such urls instead of user to type http://localhost:8080/test/index.jsp.

thanks in advance
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two steps
1) add the mapping 127.0.0.1 www.test.com to you hosts file
2) in your Tomcat context config, add an alias for www.test.com

Once this is done, local requests to www.test.com will be sent to your computer, when Tpmcat sees the request it will look at the HTTP host header (www.test.com) and connect to the correct context.
 
Bartender
Posts: 20982
128
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A domain name is nothing but an entry in the Internet's "telephone book" that the client's browser users to find the server's IP address. The "hosts" file is a local telephone book, so it can be used to lookup IP addresses for the machine on which it resides, but for the internet at large, the usual procedure is to use a Domain Name Server. DNS provides a more general database of domain names and addresses and it normally chained to upstream domain name servers which form a network that's headed by about 13 global DNS systems.

You'd register a domain name by purchasing the rights to it from a domain name registrar such as Verisign or GoDaddy.

Getting the "8080" off the URL is harder. DNS only resolves IP addresses, not port numbers. When a web browser makes a request to a server, if there's no port number in the URL and the selected protocol is "http", the port addressed will be port 80. For "https", it's 443. That means your Tomcat server must be accessible via those port numbers.

There are 2 ways to do that. One is to change the port settings in the Tomcat server.xml file. If Tomcat is the only webserver on that machine, it's the simplest way. Production machines often offer more than just J2EE services, so there's often a general-purpose server such as the Apache http server installed as well. For that case, a connector links the port 80 requests which go to Apache to the Tomcat server. By default the connection is made by Apache to Tomcat's port 8009.

There are 2 lesser-used options as well. One is to use a proxy server such as Squid. Basically, the proxy server is doing a scaled-down version of what Apache does. The other way, on Linux systems is to use the port translation feature of netfilter/iptables. Although netfilter is most commonly used as a firewall, it can also translate port and/or IP addresses so that you can leave Tomcat on port 8080, but the netfilter will route traffic targeting port 80 to it. I use a variation of this technique to allow my virtual machines to have public addressability.
 
Vinod Vinu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please i didn't understand by

Tomcat context config


where it is exactly?
 
Tim Holloway
Bartender
Posts: 20982
128
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vinod Vijay wrote:please i didn't understand by

Tomcat context config


where it is exactly?



The Tomcat context config is a file containing a Tomcat Context element definition. It can be located in the WAR's "META-INF/context.xml" file, in the TOMCAT_HOME/webapps directort or in the TOMCAT_HOME/conf/Catalina/localhost directory. Or embedded into server.xml (but please don't!).

However that just defines what webapp a request made to the Tomcat server will be routed to, so I'm not quite sure how it applies to the idea of simplifying the URL domain/port components.
 
Good night. Drive safely. Here's a tiny ad for the road:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!