Single logo
  • Courses
  • Blog
  • About
Join on SkoolJoin on Skool

In this topic

JSP and Servlets
  • Servlets and JSP: What a Servlet Container Does and How a JSP Becomes a Servlet
  • Set Up Tomcat 11 and a Maven Web Project in IntelliJ IDEA
  • The Servlet Request Lifecycle: @WebServlet, web.xml, init, doGet and destroy
  • Servlet Request Parameters, and Forward vs Redirect
  • Run a Java Web App in Docker: Tomcat 11 With One Compose Command
  • Sessions, Cookies and Filters in Java Servlets: Log In Once, Stay Logged In
  • Servlets and JSP: What a Servlet Container Does and How a JSP Becomes a Servlet
  • JSP Scripting: Expressions, Scriptlets, Declarations, Comments and Includes
  • JavaBeans and JSP Scopes: Page, Request, Session and Application
  • JSP Expression Language Step by Step: ${...} for Beans, Maps, Lists, Params and Scopes
  • JSTL Core Tags: c:set, c:out, c:if, c:choose and c:forEach
  • JSTL Functions and Formatting: fn:length, fn:toUpperCase, fn:contains, fmt:formatNumber and fmt:formatDate
  • Maintaining and Migrating Legacy JSP With AI: Explain the Page, Refactor to a DAO, Servlet and JSTL, Then Move It to React
  • MVC and the Front Controller With Servlets and JSP
  • Forms With JSP and Servlets: Handle the POST and Validate on the Server
  • Mini App With Servlets and JSP: Login, Logout and a Shared Web Template
  • SQLite and a JDBC Connection Pool in a Java Web App
  • Users CRUD With Servlets and JSP, Part 1: Add and List Through a DAO
  • Users CRUD With Servlets and JSP, Part 2: Update and Delete
  1. Blog
  2. /
  3. JSP and Servlets
  4. /
  5. Servlets

Set Up Tomcat 11 and a Maven Web Project in IntelliJ IDEA

Set JAVA_HOME, install Tomcat 11 on a free port, create a Jakarta EE web application with Maven in IntelliJ IDEA, read its folders and pom.xml, and run it on Tomcat.

Chaand Sheikh

·27 November 2026·Updated 28 November 2026Servlets

What you will learn

  • Set JAVA_HOME on Windows so Tomcat can find Java
  • Install Tomcat 11 on Windows, and know how to get it on Linux
  • Create a Jakarta EE web application with Maven in IntelliJ IDEA
  • Read the project layout and run the app on Tomcat with one click

Before you start

  • Install Java 25 (JDK) and IntelliJ IDEA
  • Maven basics

Before you can run a servlet or a JSP you need three things: Java that other tools can find, a servlet container (Tomcat 11), and a web project that builds into a .war. This article sets up all three on Windows and runs a Hello World page.

Four steps in order: set JAVA_HOME, install Tomcat 11, create a Jakarta EE Maven project in IntelliJ, run it on Tomcat. 1 JAVA_HOMEwhere Java lives 2 Tomcat 11installer, a free port 3 Maven projectJakarta EE template 4 Rundeployed, page opens
The four steps, in the order you do them.

Step 1: set JAVA_HOME

Windows should know where Java lives, because Tomcat and other tools look for it through JAVA_HOME. There can be several JDKs on one machine, so first find the one IntelliJ uses: open any run configuration and look at the JDK list. On the lecture machine the path is under the user folder, in .jdks, a Microsoft build of JDK 25. Yours will be different.

  1. In Windows search, type system and open Edit the system environment variables.
  2. Click Environment Variables.
  3. Under System variables, click New. Name: JAVA_HOME. Value: the path of your own JDK folder.

If your project folder lives in Google Drive, IntelliJ will also show a desktop.ini file in every folder. They are of no use in a project. Hide them in Settings > Editor > File Types > Ignored Files and Folders: click plus, type desktop.ini, then Apply.

Step 2: install Tomcat 11

Searching for Tomcat also turns up TomEE, which adds more of Jakarta EE on top. We want plain Tomcat (the difference is explained in Servlets and JSP: what Tomcat does).

  1. Go to tomcat.apache.org, and under Download click Tomcat 11. In the recording the current version was 11.0.27.
  2. Under Binary Distributions, take the Windows Service Installer and run it.
  3. Accept the licence. On the configuration page the HTTP connector port is 8080 by default. That port is popular and other programs often take it, so the lecture uses 9002. Any free port works. Keep the service name.
  4. The Java path is filled in from JAVA_HOME. If it's empty, pick your JDK folder.
  5. Keep the install folder under Program Files\Apache Software Foundation\Tomcat 11.0. A "folder is not empty" message only means an older Tomcat was there; click OK.
  6. At the end, untick Run Apache Tomcat and Show Readme. IntelliJ will start Tomcat for us.

On Linux or macOS there's no installer like this. Ask an AI assistant something like "how do I install Tomcat 11 on Ubuntu?" The answer is a short list of commands: install OpenJDK, check java -version, download the Tomcat archive with wget and extract it.

Step 3: create a Jakarta EE web project

  1. In IntelliJ, File > New > Project, and under Generators pick Jakarta EE.
  2. Name it HelloWorld. Template: Web application. It comes with a servlet, a web.xml and an index.jsp.
  3. Application server: the Tomcat you just installed. If it isn't listed, click New, choose Tomcat Server and point it at the Tomcat folder. TomEE and WildFly show up in the same list.
  4. Build system Maven, group org.studyeasy, JDK 25. Click Next.
  5. Version Jakarta EE 11, with only the Servlet dependency. Click Create and let Maven import the project.

The folder layout

HelloWorld
├── pom.xml
└── src/main
    ├── java/org/studyeasy/helloworld
    │   └── HelloServlet.java
    └── webapp
        ├── index.jsp
        └── WEB-INF
            └── web.xml

Java code goes under src/main/java. Pages go under src/main/webapp, with configuration in WEB-INF. At the root is pom.xml, Maven's file. Its key lines say the project is packaged as a war and depends on the servlet API:

<groupId>org.studyeasy</groupId>
<artifactId>HelloWorld</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<dependencies>
    <dependency>
        <groupId>jakarta.servlet</groupId>
        <artifactId>jakarta.servlet-api</artifactId>
        <version>6.1.0</version>
        <scope>provided</scope>
    </dependency>
    <!-- plus junit-jupiter-api and -engine with scope test -->
</dependencies>

The provided scope matters: Tomcat already has the servlet API, so Maven compiles against it but does not pack it into the war.

The generated servlet answers /hello-servlet, set by its annotation:

package org.studyeasy.helloworld;

import java.io.*;

import jakarta.servlet.http.*;
import jakarta.servlet.annotation.*;

@WebServlet(name = "helloServlet", value = "/hello-servlet")
public class HelloServlet extends HttpServlet {
    private String message;

    public void init() {
        message = "Hello World!";
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/html");

        // Hello
        PrintWriter out = response.getWriter();
        out.println("<html><body>");
        out.println("<h1>" + message + "</h1>");
        out.println("</body></html>");
    }

    public void destroy() {
    }
}

Step 4: run it on Tomcat

With Tomcat set up, the run configuration at the top of IntelliJ shows Tomcat with a green run button. Click it.

  • IntelliJ builds the project, and Tomcat starts in the Services window. You'll see it run catalina.bat run from the Tomcat folder in Program Files.
  • Then: Artifact is deployed successfully. The war is on the server.
  • The browser opens localhost:9002/HelloWorld_war_exploded (the port picked during install) and shows Hello World from index.jsp.
  • The link on that page points to /hello-servlet, the address the servlet answers.

Common mistakes

  • Copying someone else's JDK path into JAVA_HOME. Use the folder from your own machine.
  • Keeping port 8080 when another program already uses it. Tomcat fails to start; choose a free port.
  • Picking TomEE or WildFly by accident in the server list. They work differently from the plain Tomcat used here.
  • Looking for the page at localhost:9002/. IntelliJ deploys under a context path such as /HelloWorld_war_exploded.

Quick recap

StepResult
JAVA_HOMETools can find your JDK
Tomcat 11 installerTomcat on a free port (9002 in the lecture)
Jakarta EE projectMaven web app packaged as a war
RunDeployed to Tomcat, index.jsp in the browser

With this running, move on to the servlet request lifecycle.

Keep going in JSP and Servlets · 2 of 19

Previous
Servlets and JSP: What a Servlet Container Does and How a JSP Becomes a Servlet
Next post
The Servlet Request Lifecycle: @WebServlet, web.xml, init, doGet and destroy
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

FULL STACK JAVA : JAVA + JSP + SPRING BOOT AI + REACT + VIBE

Java 25, JSP, Hibernate, Spring Boot 4, REST APIs, React and Spring AI.View on Udemy ↗: FULL STACK JAVA : JAVA + JSP + SPRING BOOT AI + REACT + VIBE (paid course, opens in a new tab)

Related posts

Servlets and JSP: What a Servlet Container Does and How a JSP Becomes a Servlet

A JSP looks like HTML with a little Java, yet Tomcat runs it as a servlet. See what a servlet container does for each request, what the generated hello_jsp.java looks like, what a .war holds, and Tomcat vs TomEE.

The Servlet Request Lifecycle: @WebServlet, web.xml, init, doGet and destroy

A servlet is a Java class that answers a URL. Follow one request through Tomcat, map servlets with @WebServlet and web.xml, build a page from a list, and watch init, doGet and destroy run.

Servlet Request Parameters, and Forward vs Redirect

Read ?name=Emma with getParameter, then hand a request on two ways: a forward keeps one request and its attributes, a redirect makes the browser ask again and the attribute is gone.

Run a Java Web App in Docker: Tomcat 11 With One Compose Command

Run a servlet project without installing Tomcat: one docker compose command builds the WAR with Maven on Java 25, starts Tomcat 11 in a container, and serves the app on localhost:8090.

On this page

  • Step 1: set JAVA_HOME
  • Step 2: install Tomcat 11
  • Step 3: create a Jakarta EE web project
  • The folder layout
  • Step 4: run it on Tomcat
  • Common mistakes
  • Quick recap
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

FULL STACK JAVA : JAVA + JSP + SPRING BOOT AI + REACT + VIBE

Java 25, JSP, Hibernate, Spring Boot 4, REST APIs, React and Spring AI.View on Udemy ↗: FULL STACK JAVA : JAVA + JSP + SPRING BOOT AI + REACT + VIBE (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact us
Legal
Terms of UsePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.