aspose file tools*
The moose likes Tomcat and the fly likes TCP port for server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "TCP port for server" Watch "TCP port for server" New topic
Author

TCP port for server

Suhas Wadadekar
Ranch Hand

Joined: May 16, 2006
Posts: 95
Hi,

How can we set the port number on which a server (Apache Tomcat, for example) listens to?

I want to change it from 8080 to 9090. Dont ask me why.

Also, if Tomcat listens to port to 8080, what goes through 80.

Feel free to rip me apart if I am asking some real basic and stupid questions
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Suhas Wadadekar wrote:
I want to change it from 8080 to 9090. Dont ask me why.

Also, if Tomcat listens to port to 8080, what goes through 80.


1) Look in install_dir/conf/server.xml for 8080
2) It is yours system, so only you know what goes through port 80.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

Port 80 is the conventional (default) port for the HTTP protocol. In other words, any URL in the form "http://www.server.com" is effectively just a shorthand for "http://www.server.com:80".

Any program that wants to can listen on port 80, although in some OS's, it will have to have special privileges since there's an old convention that ports below 4096 are "protected". Most often you'll find the Apache HTTP server there, although any webserver can live there. IIS is also serving port 80. And, of course, you may not have any webserver installed and listening to port 80 at all.

80 is just a number. I could just as easily configure a mail server to listen on port 80, except that it would be really confusing.


Customer surveys are for companies who didn't pay proper attention to begin with.
Suhas Wadadekar
Ranch Hand

Joined: May 16, 2006
Posts: 95
Thanks Misha, Tim again. Do you guys work in tandem?

Anyways...Misha I took a look at server.xml. I believe this line does the trick
<Connector port="8080" .....

I can change it to some other port number.

About port 80, I am still not sure. Can I change the above line to say ><Connector port="80" .....?
Also if I understood you correctly Tim, that means most of the web servers in use are configured for port 80, so that users need not type in the port number.
For example, the web server hosting javaranch.com would be set on port 80 and hence we can get away by requesting www.javaranch.com instead of www.javaranch.com:<some port number other than 80>
Am I right?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

You're on track! Yes, JavaRanch does respond to http on port 80. And yes, you can - and people often do -set Tomcat's http port to 80 just like you said. The only requirement is that no other application can have opened port 80 for listening first, since no more than one program can own a given port number. The netstat command can be used to check for ports in use.

Tomcat actually uses about 5 different ports, more or less, including the http port (8080), https port (8443), the AJP (Tomcat connector) port and a control port. And I think I've forgotten 1 or 2. However, it's up to you which ports to relocate (if any). Tomcat doesn't care, as long as what comes in is consistent with the protocol that that particular port is intended to handle.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: TCP port for server