Install Tomcat 9 on Windows 10 and CentOS


Do you know what is Web Application?

  • If Yes, you must be aware about Web Server, Am I right? E.g. Tomcat, JBoss, etc.

Tomcat is a Open Source (Yes you heard it right) Web server by the Apache Software Foundation.  It implements Java EE specifications such as JavaServer Pages (JSP), Java EL, Java Servlet, and WebSocket.

  • Why we need to use Tomcat?

We can use tomcat to provide a “pure Java” Runtime Environment or HTTP web server environment for Java code to run in.

  •  How to Download Apache Tomcat 9 on Windows 10?

Before we start we need to ensure that JRE / JDK is installed on machine. The simplest way to check for java is execute java command in command prompt. If it says external or internal command not found, in that case we need to install JDK first. To download JDK, http://www.oracle.com/technetwork/java/javase/downloads/index.html.  Download appropriate JDK for tomcat. For tomcat 9 recommended JDK is 8 or later. Refer http://tomcat.apache.org/whichversion.html.
Once the JDK is installed next steps is to download Tomcat, which can be downloaded from apache tomcat site https://tomcat.apache.org/download-90.cgi. To directly download exe click Tomcat9.exe .

Click on the apache-tomcat-9.0.0.M3.exe that will open Welcome to the Apache Tomcat Setup Wizard, Click on Next.

16.1 Welcome to the Apache Tomcat Setup Wizard

Click on “I Agree” on the License Agreement (As if you are going to click on Cancel-Pun Intended)

16.2 Apache Tomcat License Agreement

On the next scree, we can choose features or components we want to install. Host Manager and Examples are not selected by default. In our case we will select it and click on Next.

16.3 Apache Tomcat features or components

Here, we have a golden chance to customize basic configuration related to Port, Windows Service Name, and Tomcat Administrator Login. Please note Tomcat Administrator Username, Password, Roles (admin-gui,manager-gui); we will verify how it is used and where it is configured later in the post. Click on Next.

16.4 Apache Tomcat Configuration

Configure Java Virtual Machine or JVM Path here. We have to select Java SE 7.0 or Later JRE to install Apache Tomcat 9. Click on Next.

16.5 Apache Tomcat Java JRE Path

Here is a complicated decision to select Install Location (Just Kidding). Click on Next…NO, here we need to click on Install 🙂

16.6 Apache Tomcat Installation Directory

Verify the Installation process, it may take 1-2 minutes. Click on Next.

16.7 Apache Tomcat Installing

Click on Finish once Apache Tomcat Installation Wizard in completed..

16.8 Apache Tomcat Setup Completed

Immediately, Service Manager will start a Apache Tomcat 9.0 Tomcat 9 Service.

16.9 Apache Tomcat Service Manager

Verify the status of Windows Service in the Taskbar.

16.10 Apache Tomcat Taskbar

Verify Display Name, Service Name, Startup Type – Here it is manual. We can Start, Stop, Pause, or Restart Service from the same dialog box.

16.11 Apache Tomcat Properties Manual

To change the Startup type, click on the List box and select “Automatic”.

16.12 Apache Tomcat Properties Automatic

Click on the Java and Logging Tabs to verify respective settings currently available. Click on Ok.

16.13 Apache Tomcat Properties Java

Open any Browser and navigate to http://localhost:8080. It will open a Home Page

16.14 Apache Tomcat Home Page

Verify Installation Directory of Apache Tomcat 9. In our case, It will be C:Program FilesApache Software FoundationTomcat 9.0

16.15 Apache Tomcat 9 Installation Directory

To Verify Manager Application Installation, Click on the Manager App Link available on Tomcat Home Page. Now, It will open a Dialog box for User Name and Password.
Recollect…
Tomcat Administrator Username, Password, Roles (admin-gui,manager-gui)? Give User name and Password configured earlier and click Ok.

16.16 Apache Tomcat Administrator Username Password

It will Open a Manager Application at http://localhost:8080/manager/html

16.17 Apache Tomcat Manager Application

Now go to Windows Explorer and open C:Program FilesApache Software FoundationTomcat 9.0conf

16.18 Apache Tomcat Conf Directory

Edit tomcat-users.xml and verify the content:
<tomcat-users xmlns=”http://tomcat.apache.org/xml”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://tomcat.apache.org/xml tomcat-users.xsd”
version=”1.0″>
<user username=”admin” password=”*********” roles=”admin-gui,manager-gui” />

16.19 Apache Tomcat tomcat-users xml

Visit Example Link from Tomcat Home Page: http://localhost:8080/examples/

16.20 Apache Tomcat Examples

To know and see Servlet Example visit http://localhost:8080/examples/servlets/

16.21 Apache Tomcat Examples Servlets

Right click on Execute Link of Hello World Servlet and Click Open in new tab.

16.22 Apache Tomcat Examples Hello World Servlet

Verify http://localhost:8080/examples/servlets/servlet/HelloWorldExample

16.23 Apache Tomcat Examples Hello World Servlet Running

Click on the Source Link available on http://localhost:8080/examples/servlets/ to get a feel about Servlet Code.

16.24 Apache Tomcat Examples Hello World Servlet Code

Similarly, navigate to http://localhost:8080/examples/jsp/

16.25 Apache Tomcat Examples JSP

Click on Execute link of JSP 2.0 Expression Language – Basic Arithmetic – http://localhost:8080/examples/jsp/jsp2/el/basic-arithmetic.jsp

16.26 Apache Tomcat Examples JSP Expression Language

Verify the source code at http://localhost:8080/examples/jsp/jsp2/el/basic-arithmetic.jsp.html

16.27 Apache Tomcat Examples JSP Expression Language
This was a very simple introduction to Tomcat, Servlet and JSP.

Leave a comment

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