File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Hiding port number in URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Hiding port number in URL" Watch "Hiding port number in URL" New topic

Hiding port number in URL

Mithun Madhu

Joined: Feb 26, 2009
Posts: 8

I have set up a J2EE application in Tomcat container in an RHEL5.3 server.
It is working fine when I give http://localhost:8080/abcd/..../*.jsp
But I want to hide the 8080 port number. i.e If I give http://localhost/abcd/..../*.jsp it should work. Is this possible?
Currently, when I try it after starting Apache and Tomcat, the code of the JSP page gets displayed in the browser.

Thanks in advance.
Imran Akbar
Ranch Hand

Joined: May 06, 2010
Posts: 63
Change the port to 80 instead of 8080 in server.xml in tomcat's conf directory

and restart.

some one has other solutions please post.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952

You can't "hide" the port number. A URL isn't primarily something to be displayed, it's something used to make a request. That's why it's called a Uniform Resource Locator.

As Imran has pointed out, you can reconfigure Tomcat to listen on Port 80 - assuming that no other server such as Apache or IIS is using it. However, that's not really "hiding" the port number, just taking advantage of the fact that an HTTP URL has an implied ":80" in in.

Customer surveys are for companies who didn't pay proper attention to begin with.
Mithun Madhu

Joined: Feb 26, 2009
Posts: 8
Thanks for your replies...
Actually, I have Apache server configured in Port 80. Therefore when I give, http://localhost/abcd/..../*.jsp it is going to the Apache server. Is it possible to redirect to Tomcat from there?
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404

The Tomcat-Apache HOWTO has the information you need. It is quite easy to have Apache HTTPD fronting Tomcat, and is one of the recommended configurations.

The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952

Traditionally, the way to link up Apache httpd and Tomcat was to use a Tomcat connector such as the coyote/mod_jk connector.

Eventually this is probably going to be phased out, as Apache has been modified to be able to use its mod_proxy module for linking Apache and Tomcat. At the moment, as I understand it, there are still cases where mod_jk is necessary, but I do have one server happily running using mod_proxy.
I agree. Here's the link:
subject: Hiding port number in URL
Similar Threads
Unable to start JBoss 5
webapp not on 8080 and html:base
Problem in placing JSPs in webapps folder
Tomcat web app configuration error
Problem with Tomcat 4.0, can't see Tomcat Welcome Page.. pls helllpppp!!