Tomcat – Overview, Installation & Configuration

Introduction to Tomcat:

Tomcat is a lightweight tool started by James Duncan Davidson, who is a software architect at Sun Microsystems. It was initially under sun microsystems but later on given to the apache software foundation and made it open-source, Now it is completely maintained and developed by apache software foundation. 

however, It is a web server that can handle HTTP requests/responses and a servlet container that can handle Java Servlets, JSP, Expression Language, Web Sockets. therefore, It is called a Web Server but not an application server because it does not implement all features of the Java EE API. It can only handle Web ARchive files (WAR) type but not Enterprise Archive Files (EAR).

Installation of Apache Tomcat:

Check the version of java in your system initially by going into the command prompt and type java -version. You can update the java version by downloading the latest JDK versions. 

  • Navigate to the home page, In the left side panel of the home page.
  • Click on the “which version?”,  check for supported versions and download the latest and stable version of apache tomcat from the left side of the page Tomcat 10 (alpha), tomcat 9, etc. 
  • Alpha indicates that it is still in the testing phase so download the tomcat 9 version.
  • Double click on the installed file.
  • Click next.
  • Click on I agree.
  • Select all checkboxes and click Next.
  • The default working port number for the tool is 8080. So if you want to change then you can change at the time of installation and provide a username and password.
  • Let these be defaults or make sure to choose a good port number for the connector port because the port number identifies the process in a computer.
  • Set the username and password or you can leave it.
  • Set the path for your jre (java version<=1.8) or jdk(>1.8 version).
  • Click on Install.

Checking for successful installation of apache tomcat:

To check for the version of tomcat or ensuring the successful installation of the apache tomcat.

  • Open the command prompt. Go for the its directory folder by typing the below command or else find the path you have chosen to install and then follow :
    cd “C:\Program Files\Apache Software Foundation\Tomcat 9.0”
  • Now type Java -cp lib.catalina.jar org.apache.catalina.util.ServerInfo

After installing navigate to the specified path while installation and in the apache tomcat directory many files and folders will be created.

  • bin: It consists of the startup, shutdown scripts, and tomcat .exe files.
  • Conf: We can add users in the tomcat_users.xml file and it has other configuration files.
  • Lib: It consists of required jar files for the application.
  • Webapps: we copy our WAR files manually or deploy our web applications.
  • Work: It consists of temp files for our deployed web apps.

Working:

To start the tomcat by command prompt open command prompt enter cd “C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin”. Next enter the startup.bat command it starts the its server.

C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin>startup.bat

Goto browser and type localhost:port-number for example localhost:8080. It opens up the tomcat server main page. Explore all the options to check for the server status click on it and enter the username and password entered at the time of installation. Click on the manager app and there you can start and stop any deployed applications.

so, You can create your own web application and deploy it in the web apps folder and then go to the browser and check for the new application there.

You can check for the java servlet tutorials for creating the servlet applications.

As above mentioned that the tomcat supports Servlets, JSP, Expression Language, Web Sockets but it is a server that works with servlets. Everything is converted into servlets, For example, JSP pages are internally converted into servlets and these servlets are handled. 

Tomcat consists of a  classloader hierarchy and a Thread Pool. The maximum number of threads by default would be set is 200, it specifies that maximum threads allowed to run at a given time. A web application on deploying into tomcat, it scans the files, checks the deployment descriptor file (web.xml), and maps the Servlets (and JSPs) to their respective requests and will be made available.

On mapping, the requests to the specific servlets will be loaded and the task would be carried out and provides the response. Servlets are controllers whereas web.xml is the main thing that describes the relationship for a specific request.

Conclusion:

Tomcat is an Http server and servlet container. It is in use for hosting Web Applications. It’s a free and open-source java technology maintained by apache. It supports servlets, JSP, Expression Language, and Web Sockets.

References for downloads:

written by: Laxmi Narayana

reviewed by: Soutik Maity

If you are Interested In Machine Learning You Can Check Machine Learning Internship Program
Also Check Other Technical And Non Technical Internship Programs

Leave a Comment

Your email address will not be published. Required fields are marked *