Tomcat is a very popular container and server for Java web applications and is being developed by a large community of the Apache Software Foundation (ASF). It enjoys great popularity in ecomomic and scientific disciplines and is considered to be robust, reliable and high-performant. In Java enterprise applications, it is mostly part of a J2EE application server like OpenEJB, Geronimo, JBoss or Glassfish and handles incoming requests to deployed web applications. Tomcat can also be used as module of an Apache HTTP Server (other modules exist for CGI or PHP support). Nevertheless, it is increasingly used as standalone web server.
If Tomcat is started as web server it will be bound to the specific TCP/IP address of the running computer and identified by a preconfigured port address where it is listening for incoming user requests. The transfer protocol on which requests are based is the HTTP protocol which allows to access any web application via web browser. The aim of the web container is to forward the requests to the intended web applications.
Various versions of Apache Tomcat are available which differ in the underlying architecture. Apache Tomcat implements the Java Servlet/ JSP specifications and each major version implements another specification whereas minor versions are mostly bugfixing and maintainance versions. E.g. both Tomcat versions 5.0 and 5.5 implement the Sun Servlet/JSP specifications 2.4/2.0 whereas version 6.0 implements the Servlet/JSP specifications 2.5/2.1 which lead to a significant jump in functionality. Further, each tomcat version is spitted into various modules that provide additional functionality, e.g, administration and monitoring modules and must be downloaded and installed separately. To run Tomcat as web container and server, the Core distribution is needed.
If you use Windows, you can download the Windows Server Installer version of the Core distribution. The installation is straight-forward. You should only take care, that the installation path to the Tomcat directory contains no whitespaces because then errors can occur when starting Tomcat as web server. We recommend a path something like that: C:\Programme\Apache\Tomcat.
The installation path to your Tomcat is referred to as CATALINA_HOME and is usually set as user/system variable. You can check this by opening the command prompt (Start, Ausfuehren and type cmd followed by pressing enter). Then type echo %CATALINA_HOME% and press enter. This command will print the installation path to your Tomcat directory on the console if CATALINA_HOME is set as user/system variable.
If Tomcat was successfully installed, you should notice a new icon in the Windows System Tray. With the help of this icon, you can start, stop and configure Tomcat.
If you started the server using the default configuration, you should be able to access the web server via URL http://localhost:8080 in your favourite web browser.
#installation path to our tomcat directory, #in our example we use 5.5 #Please set TOMCAT_HOME to your Tomcat installation directory TOMCAT_HOME="/opt/programs/apache-tomcat-5.5" CATALINA_HOME=$TOMCAT_HOME export TOMCAT_HOME CATALINA_HOME # path to our java installation directory #the following uncommented 3 lines must be done if #the 'javac' command is not found in the terminal #Please set JAVA_HOME to your Java SDK directory!! JAVA_HOME='/usr/java' PATH=$JAVA_HOME/bin:PATH export PATH JAVA_HOME
If you have done the previous steps, you should be able to start Tomcat by typing $CATALINA_HOME/bin/startup.sh followed by pressing enter. If Tomcat is really running, the URL http://localhost:8080 displays the Tomcat welcome page in any webbrowser of your choice. To stop Tomcat, you can use the command $CATALINA_HOME/bin/shutdown.sh.
The configuration files of Tomcat are located in the CATALINA_HOME/conf directory and allow to change a couple of security settings.
<!-- 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" />
<!-- Define a non-SSL HTTP/1.1 Connector on port 8080 --> <Connector port="8089" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" />
<user username="Hugo" password="Boss" roles="manager,tomcat"/>
External libraries are located in the CATALINA_HOME/common/lib directory which are globally accessible by all deployed web applications.
By default, Tomcat's log files are stored in the CATALINA_HOME/log directory. The evaluation of these files can be very useful if errors occur during the deployment of your web application as well as during it's execution.