Scrivio Interview library
ConceptFoundations5 min read · updated 12 November 2026

Which embedded servlet containers does Spring Boot support, and how do you switch from Tomcat to Jetty?

Spring Boot's web starter uses Tomcat by default, and Boot also supports Jetty; Undertow was supported in Spring Boot 3 but removed in Spring Boot 4 because it did not support the newer Servlet version (check your version). To switch to Jetty we exclude spring-boot-starter-tomcat from the web starter and add spring-boot-starter-jetty, and we configure whichever container we use through server.* properties.

Why this question is asked

In Spring Boot the servlet container is not something we install; it is a library inside our jar. That makes the choice easy to change, but it also means we need to know what is on the classpath, because Boot picks the container from it. Interviewers ask this to check that we understand how starters and auto-configuration choose the server, and that we know the recent change to the supported list. In this answer, we will recap what an embedded container is, see which containers Boot supports, switch from Tomcat to Jetty step by step, and look at how server properties configure them.

1A Quick Recap of Embedded Containers

A servlet container is the server that accepts HTTP connections, manages threads and calls our servlets; in Spring MVC the main servlet is the DispatcherServlet. In the past we installed a container such as Tomcat on a server and deployed a war file into it. Spring Boot turns this around: the container is a dependency, Boot starts it inside our main() method, and the result is one executable jar.

Boot decides which container to start through auto-configuration. It looks for container classes on the classpath and creates the matching web server factory, such as TomcatServletWebServerFactory or JettyServletWebServerFactory. So switching containers is a matter of changing dependencies.

2Which Containers Spring Boot Supports

spring-boot-starter-web (renamed spring-boot-starter-webmvc in Boot 4, with the old name still available; check your version) pulls in spring-boot-starter-tomcat, so Tomcat is the default. Jetty is supported through spring-boot-starter-jetty. Spring Boot 2 and 3 also supported Undertow through spring-boot-starter-undertow, but Spring Boot 4 dropped it because Undertow did not support Servlet 6.1, the Jakarta EE 11 baseline Boot 4 requires. A service on Undertow must move to Tomcat or Jetty when upgrading.

Embedded servlet containers in Spring Boot
ContainerStarterSpring Boot 3.xSpring Boot 4.x
Tomcatspring-boot-starter-tomcatDefaultDefault
Jettyspring-boot-starter-jettySupportedSupported
Undertowspring-boot-starter-undertowSupportedRemoved
Check your exact version; reactive WebFlux apps use Reactor Netty by default instead.

3Switching From Tomcat to Jetty

We need two changes. First we exclude Tomcat from the web starter, otherwise both containers are on the classpath and Boot keeps choosing Tomcat. Then we add the Jetty starter.

XML
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
// Startup log after the change:
// o.s.b.w.e.jetty.JettyWebServer : Jetty started on port 8080 (http/1.1)

In Gradle the same exclusion is written as configurations { implementation { exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat' } } or on the dependency itself. Notice that the startup log names the container; it is the quickest way to confirm the switch worked. We can also run mvn dependency:tree and check that no tomcat-embed-core jar remains, since another starter or library can bring Tomcat back transitively.

4Configuring the Container With server.* Properties

Boot exposes container settings as properties. General ones apply to every container: server.port, server.address, server.servlet.context-path, server.compression.enabled, server.ssl.* and server.servlet.session.*. Container-specific ones sit under their own prefix: server.tomcat.threads.max or server.tomcat.accept-count for Tomcat, and server.jetty.threads.max or server.jetty.threads.min for Jetty.

Properties
server.port=8081
server.servlet.context-path=/api
server.compression.enabled=true
# Tomcat-only (ignored after switching to Jetty)
server.tomcat.threads.max=200
# Jetty equivalents
server.jetty.threads.max=200
server.jetty.threads.min=8

But there is a catch: after a switch, the old container's properties are simply ignored, so tuning silently disappears. We should translate each server.tomcat.* setting to the Jetty equivalent, and review any code that customises the container directly, such as a WebServerFactoryCustomizer<TomcatServletWebServerFactory> bean, which must be rewritten for Jetty.

5Follow-up questions

Can we still deploy a Spring Boot application as a war?

Yes. We extend SpringBootServletInitializer, package as war, and mark the embedded container dependency as provided so it does not clash with the external server. The external server must support the Servlet version our Boot version needs, for example Tomcat 10.1 or later for Boot 3.

Why would anyone switch from Tomcat to Jetty?

Usually for a specific reason: a team standardising on one container across services, a Jetty feature they rely on, or a smaller footprint in some workloads. For most services the difference is small, so Tomcat as the default is a reasonable choice unless there is a measured reason.

What about WebFlux applications?

A WebFlux application with spring-boot-starter-webflux runs on Reactor Netty by default, not on a servlet container. It can also run on Tomcat or Jetty through their reactive adapters, but most teams keep Netty.

6Conclusion

In this answer, we saw that Spring Boot starts the servlet container from the classpath, that Tomcat is the default and Jetty is the supported alternative, and that Undertow support ended with Spring Boot 4. Switching to Jetty means excluding spring-boot-starter-tomcat and adding spring-boot-starter-jetty, and container settings move between server.tomcat.* and server.jetty.* properties, which is easy to forget during a switch.

What to say in the interviewAbout 70 seconds aloud

Open with

Spring Boot embeds the servlet container as a library and auto-configuration starts whichever one it finds on the classpath. The web starter brings in spring-boot-starter-tomcat, so Tomcat is the default.

Then, if they want more

Jetty is supported through spring-boot-starter-jetty. Undertow was supported up to Spring Boot 3, but Spring Boot 4 removed it because Undertow did not support the newer Servlet version that comes with Jakarta EE 11, so I would check the version before relying on it.

To switch to Jetty, I add an exclusion for spring-boot-starter-tomcat on the web starter and add the Jetty starter. Then I check the startup log, which says Jetty started on port 8080, and run dependency:tree to make sure no other dependency pulls Tomcat back in. Configuration is through server properties.

The general ones like server.port, context path, compression, SSL and session settings work for any container, while tuning is container-specific, under server.tomcat or server.jetty. So during a switch I translate the Tomcat tuning to Jetty properties and rewrite any WebServerFactoryCustomizer written for Tomcat, because the old settings are silently ignored.

About this answer

Last updated
12 November 2026
Versions it names
Spring Boot 4, Jakarta EE 11, Spring Boot 2, Spring Boot 3
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Jakarta EE specifications
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Which embedded servlet containers does Spring Boot support, and how do you switch from...": https://scrivio-interview-library.netlify.app/java/servlets/fe1fbc8779/