• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

TCP port for server

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 470
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Suhas Wadadekar
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic