Easy to Learn Java: Programming Articles, Examples and Tips

Start with Java in a few days with Java Lessons or Lectures


Code Examples

Java Tools

More Java Tools!

Java Forum

All Java Tips


Submit News
Search the site here...
Search the JavaFAQ.nu
1000 Java Tips ebook

1000 Java Tips - Click here for the high resolution copy!1000 Java Tips - Click here for the high resolution copy!

Java Screensaver, take it here

Free "1000 Java Tips" eBook is here! It is huge collection of big and small Java programming articles and tips. Please take your copy here.

Take your copy of free "Java Technology Screensaver"!.

Findout in one minute why Tomcat runs on 8080 port, not 80?

JavaFAQ Home » JSP, Servlets Go to all tips in JSP, Servlets

Bookmark and Share

Port reconfiguration on Tomcat 5.X...

When you first time install Tomcat you will find out that it can be used right away to serve HTML pages over HTTP and HTTPS. Default ports are 8080 and 8443. Not so funny perhaps to have port number in your site URL:  http://www.mysite.com:8080/   It looks really old and strange. Why by default is 8080, not 80?  The reason is that often port 80 is already used by web server like Apache or IIS. It is done to avoid application "collisions" on the same port. 

Connector, what is that?

Before I will continue with Tomcat's configuration, I want to explain "connector" term which is used everywhere in Tomcat's documentation but not clearly defined. I tried to find the definition of "connector" term hopelessly on the Tomcat web site. Even Google which is usually finds everything, even things we do not want to expose on the web, could not help me. Suddenly I found the definition in server.xml file which configures those connectors Smile. So, according to it:  

-A "Connector" represents an endpoint by which requests are received and responses are returned.  Each Connector passes requests on to the associated "Container" (normally an Engine) for processing. 

Actually a connector is server which runs on specified port and provides some part of Tomcat's functionality. I foresee a question about Apache server:

            If Tomcat can serve HTML pages do we need Apache server on our system also?           

The answer to this question is depends on how much not JSP/Servlet generated content do you have.

- If most of content is generated by JSP/servlets and you have also plain HTML pages then probably it is enough with just Tomcat.
- If you have much "HTML" traffic, be aware that Apache is more efficient to handle heavy loads than Tomcat.
- If you need another languages to work with, like Perl or PHP then better to add Apache. 

In the second case Tomcat and Apache can work in tight cooperation. All HTTP/HTTPS requests are handled by Apache and then depending on what is content required, JSP/servlets generated pages can be requested by Apache from Tomcat server and rest served by Apache itself. 

JK connector provides such cooperation. A few kinds of JK connector exists, for Apache, IIS and more. The connector to use with Apache has name mod_jk.

Generally saying JK is a project covering web-servers to Tomcat connectors, whereas mod_jk is the Apache module developed in JK. 

            Domino web server support is implemented on JK, using a redirector called dsapi redirector.
            IIS web server support is implemented on JK, using a redirector called isapi redirector.
            Netscape/iPlanet web server support is implemented on JK, using a redirector called nsapi redirector.          

I think this brief introduction into connectors will help you to make your choice.

Apache-Tomcat configuration is well described on Connectors Doc page here: http:// tomcat.apache.org/connectors-doc/  

Now I will just give you small info where you can change port numbers for running Tomcat independently. 

Look at server.xml in conf directory. Here you will find all active connectors. Disable all which you do not use. For example:

            -           AJP 1.3 Connector on port 8009, active.

            Surround the next two lines with "<!-- " and "-->":

            <Connector port="8009"
                 enableLookups="false" redirectPort="8443" protocol="AJP/1.3" /> with "<!-- " at the beginning and "-->"
at the end.                

After disabling it will look like this:

            <!--      <Connector port="8009"
                 enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />  -->

Configuration parameters for plain HTTP are here:

<!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
    <Connector port="8080" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true" />

and for HTTPS respectively here:

<!-- Define a SSL HTTP/1.1 Connector on port 8443 -->


    <Connector port="8443" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" disableUploadTimeout="true"
               acceptCount="100" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />

In the last case HTTPS connector is disabled. 

I recommend you to enable gzip compression: compression="on". It will significantly reduce page sizes during their transmission over a network. All modern browsers support HTTP 1.1 protocol which has this feature. All your pages will be compressed, sent over the net and then browser will decompress them. From my experience it gives significant improvement in a page loading time.

 Printer Friendly Page  Printer Friendly Page
 Send to a Friend  Send to a Friend

.. Bookmark and Share

Search here again if you need more info!
Custom Search

Home Code Examples Java Forum All Java Tips Books Submit News, Code... Search... Offshore Software Tech Doodling

RSS feed Java FAQ RSS feed Java FAQ News     

    RSS feed Java Forums RSS feed Java Forums

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest 1999-2006 by Java FAQs Daily Tips.

Interactive software released under GNU GPL, Code Credits, Privacy Policy