In this blog post, We will cover the installation of Tomcat 9 on
Apache tomcat server basics
Tomcat is an application server that supports running java,j2ee based applications.
Tomcat is an open-source application server built on a java framework.
It is used for web application deployment on this server. Tomcat 9 supports Servlet4 and Jsp 2.3. Tomcat runs applications using the HTTP protocol over TCP/IP protocol. The default port for tomcat installation is 80.
Tomcat provides different services like any other application servers such as JBoss, WebSphere
Tomcat Latest version 9.0.x supports following Specifications
- Servlet 4.0
- JSP 2.0
- Websocket 1.1
- JDK 1.8 or more
- OpenSSL Support
- java installation required - For tomcat 9.0.x Version, JDK 8 or more is required.
Setup Apache Tomcat 9.0 in windows:-
Following is the sequence of steps to set up and install tomcat in windows. Latest Tomcat Version is 9.0.12
Install JDK for tomcat
For Tomcat, JDK 8 or more is required,
Please make sure install JDK 1.8 version and configure the following environment variable
JAVA\_HOME=D:\\jdk path PATH=%PATH%;.;%JAVA\_HOME%\bin;
Download tomcat 9.0.x
Before downloading tomcat 9.0 to your machine, we need to find out the 32 bit or 64-bit machine you are going to install, check here to find out 32 bit or 64 bit for your machine.
Latest tomcat in apache tomcat website.
First, Download Tomcat from the apache site.
You can download from Tomcat 9.0 server from windows.apache-tomcat-9.0.12-windows-x86.zip file is downloaded to your machine, extract or unzip using WinRAR or zip tools to your drive(g:\)
let us say I have extracted to G drive like G:\apache-tomcat-9.0.12
tomcat environment variable settings
Configure Environment variables like CATALINA_HOME in the path variable.
Make the following environment settings for your tomcat.
To start Tomcat = run CATALINA_HOME\bin\startup.bat
To stop Tomcat run CATALINA_HOME\bin\shutdown.bat
Starting tomcat server
starts the tomcat server using
startup.bat. this opens the console starts the tomcat server.
Stopping tomcat server
Stopping or shutdown the tomcat server using
shutdown.bat. this opens the console stops the tomcat server.
finally, you have completed the tomcat set up in windows and got some basic ideas on the tomcat server.
tomcat server folder structure explanation
Here is the folder structure as follows
bin folder: the bin folder contains scripts for setting classpaths, start and shutdown, and running scripts. scripts with .bat extensions are for windows server and .sh for Linux box.
setclasspath.batis used to configure any classpath-related settings like JAVA_HOME etc.
startup.batis to start the tomcat as non-window service mode. We can still install tomcat as windows service, However, non-window server mode has more performance for tomcat startup.
tomcat9.exe is to start the tomcat as a window service meaning if we install tomcat as a windows service
shutdown.bat is to stop or shutdown the tomcat server.
catalina.bat is to set the tomcat environment related settings like JVM options, heap size settings, and garbage collector settings
conf folder: configuration-related files in tomcat like port number and log level changes etc.
server.xml contains settings for tomcat container like listening port number and resource configuration like JDBC data source, security settings.
tomcat-users.xml contains authentication and authorization details for the tomcat administration console tool
Lib folder contains all the jars required to run for tomcat.
This contains a bootstrap class loader for the tomcat server.
Jars in this folder are loaded into the container when the tomcat application is started. These jars are available to all the applications deployed to the tomcat container.
We can override the jars within the application.
always avoid duplicating with a different version of jars in the lib folder with your application folder. otherwise, you will be in trouble with a lot of NoClassDefFounder issues.
logs folder: contains all the tomcat server-related logs like standard out logs, access logs, and Catalina logs.
if we have any issues in tomcat, This folder is first checked to look for detailed information about the error.
temp and work folder: contain the
workfolder for your tomcat. It will act cache for your application.
web apps folder: This is the main folder where all your applications are deployed to. if you want to deploy your application, copy your web application war file to this location.
That’s about the folder structure.
Is tomcat Application Server or Web server?
Yes. Tomcat is an application server that provides the following services
- Object Management like automatic object creation, modifying, and garbage collection
- JDBC Connection pool mechanism
- Maintaining multiple nodes in the cluster setup
- 99.99 start-up time for running applications
- Configuring the different J2EE services like mbeans, enterprise objects like message beans within administrative tools
- Integration with different security frameworks like CUP with LDAP, and database realms
The advantages of the above services are that the developer need not write this and can concentrate on his business logic.
A web server is a server that serves the plain request and gives the response. Apache webserver need not be talking to the database
But in a production scenario, the Apache HTTPd server acts front controller which delegates the request to the application server. The application server talks to the database and does the business logic and sends the response to the web server, finally the web server sends the response to a client.
How to know which tomcat version is running on the machine
With the command line, you can go to the bin folder of your tomcat directory.
Run this command if you are in windows,
In Linux or Unix bash command mode
To Sump Up, You learned the following things from this tutorial.
- Apache tomcat server installation on windows
- Start and stop server
- How to find the version of the tomcat server running
- Tomcat folder structure