08. Getting started with Apache Tomcat application server by deploying a simple JEE Application

This assumes that you have set up Java, Maven, and Eclipse.

To run JEE based web apps, you need an  application server that contains a web container. There are a number of application servers like Apache Tomcat, JBoss, GlassFish, etc. This tutorial will use Apache Tomcat.

Installing & configuring Tomcat

Step 1: Download and install Apache Tomcat from

http://tomcat.apache.org/ and then “Download” on the LHS menu and then select the version. Usually the latest version.

The installing is all about unzipping it to the right folder (e.g. c:\tools). If you are running on Windows 7 or greater download the 64-bit windows zip. For example, “Tomcat 9” for Windows 10 will be “64-bit Windows zip”

Apache Tomcat Setting up

Step 2: Set up the “JRE_HOME” environment variable. E.g. c:\scripts\environment-setup.bat

Step 3: Open a DOS console by typing “cmd” on windows 10 search. Run

Step 3: Run the tomcat server as shown below:

Tomcat server starts listening on port 8080

Creating a simple web app using JEE

Step 1: Create a web project “simpleWeb” using Maven.

Step 2: Import c:\projects\simpleWeb as “Maven -> Existing Maven Projects”.

Step 3: Add the Servlet dependency to the pom.xml file.

Step 4: Define a simple servlet class in a package com.mytutorial under src/main/java. You need to first create a folder named “java” under src/main. Then create the package folders com.mytutorial under the folder java. Create a Java class named SimpleServlet.java

Step 5: The simpleWeb\src\main\webapp\WEB-INF\web.xml should be modified to

Step 6: Build the war file target\simpleWeb.war by running the “mvn package” command in a DOS console

You could also run it inside eclipse: by selecting the project “simpleWeb”, and then right-click to get the context menu followed by “Run As” –> “Maven install”.

Deploy “simpleWeb.war” to Tomcat & run

Step 1: Copy the “simpleWeb.war” to the tomcat “C:\tools\apache-tomcat-9.0.0.M21-windows-x64\apache-tomcat-9.0.0.M21\webapps” folder.

Step 2: Open a web browser and type the url


Screen shot 2014-10-19 at 5.24.34 PM

300+ Java Developer Interview Q&As

800+ Java Interview Q&As