Java Basics: What Is Apache Tomcat?
With 48% of developers using Apache Tomcat in 2022, it is one of the top Java technologies out there today. But why is it so popular, and how does it compare to other popular Java web servers and application servers?
In this blog, we give an overview of Apache Tomcat, including what it is, how it works, and why it continues to be a popular choice for Java users today.
- What Is Apache Tomcat?
- How Does Tomcat Work?
- Tomcat vs. Jetty
- Tomcat vs. JBoss / Wildfly
- Tomcat vs. WebLogic
- Final Thoughts
What Is Apache Tomcat?
Apache Tomcat is a popular open source web server and Servlet container for Java code.
As the reference implementation of Java Servlet and Java Server Pages (JSP), Tomcat was started at Sun Microsystems, which later donated the code base to the Apache Software Foundation.
Since then, multiple volunteers from Sun contributed to the product which then led to a a top-level Apache project designation in 2005. Nowadays, Apache Tomcat is widely used by many companies as it implements many of the Java EE specifications, such as:
- Java Servlet
- JavaServer Pages,
- Java Expression Language,
- Java WebSockets.
Apache Tomcat 10.0.x is the current Tomcat release at the time of this writing, and is still undergoing active development. It is the first Tomcat release to support Java Servlet 5.0, JavaServer Pages 3.0, Java Expression Language 4.0, WebSocket 2.0, and Authentication 2.0 specifications.
Is Tomcat an Application Server, or a Web Server?
Tomcat is considered a web server instead of an application server because it functions as a web server and Servlet container. It doesn’t provide the full feature set from the Java EE, but that isn't necessarily a disadvantage. Many applications require just the features that Tomcat provides, so it doesn't make sense to go with the heavier tools. You can use Apache Tomcat for production applications that process thousands of requests if the features it provides is enough. In any case, Tomcat is a production-ready tool.
Is Tomcat Still Popular?
According to our 2022 Java Developer Productivity Report, Tomcat is used by 48% of Java teams. See the full data by downloading the report today.
This is due to the fact that it is a very lightweight tool and it is free. It offers most of the basic functionality needed by many applications, it has a fast startup time, and the redeploy times are much lower compared to other tools on the market.
If you ever run into an issue, the extensive documentation will likely help you find a solution. Tomcat has very good documentation available, and what is not in the official documentation, you find it on the internet as there are many wide ranges of tutorials available.
It's also important to note that Tomcat isn't a one size fits all solution for Java applications. Picking the right server always depends on the needs presented by the application.
How Does Tomcat Work?
Tomcat is a platform-independent tool, and, as long there is Java installed, the installation is a straightforward process. You just need to download the desired version from the official website and then unpack it on your file system. You can verify that Tomcat is installed properly by running the server using a startup script in the $CATALINA_BASE/bin folder.
Once you start the server open your internet browser and navigate to URL http://localhost:8080 (if the default configuration is used). If you see a similar page as on the picture below, that means Tomcat was properly installed.
Deploying the application on to the server is easy. Tomcat supports deployment on the startup, which means you copy compressed (.WAR) or non-compressed (exploded web application) to the right directory, which is $CATALINA_BASE/webapps/.
If you prefer deploying the application on the fly, you can deploy the application to a running Tomcat server in the Tomcat Web Application Manager GUI. All the deployed applications can be managed via the Manager App in the Tomcat.
There are a few main components that Tomcat uses. The component Catalina is the actual Servlet container that implements the specification for Servlets and JavaServer Pages. The other component, Coyote, is handling all the HTTP communication and forwards the requests to the Tomcat Engine (Catalina).
📕 Related Resource: Need Tomcat Support? Talk to an Expert
Tomcat vs. Jetty
When it comes to lightweight servers, Tomcat is most often compared to Jetty. Jetty is an HTTP server and Servlet container that is often used as an embedded server. For a long time, Jetty was the only tool capable of running in embedded mode. As of now, Tomcat is already capable of running in the embedded mode as well.
Both tools are open source, with Tomcat developed under the Apache 2.0 open source license and the Jetty license managed by the Eclipse Foundation and available with Apache 2.0 and Eclipse Public License 1.0.
|Tomcat Benefits||Jetty Benefits|
|Licensed with Apache 2.0||Prioritize needs of the user community|
|High market share||Small memory footprint|
|Focus on being up to date with the latest specification||Embeddable|
|Very well documented|
Both tools are very good and share many of the same features. While Tomcat is very well documented and has a big market share, for applications that are focused on low memory footprint, Jetty might be a slightly better choice.
Tomcat vs. WebLogic Server
The full implementation of Java EE standards is available in Oracle WebLogic Server. WebLogic is a commercial project currently developed by Oracle Corporation and thus is licensed and requires buying a license in order to use for commercial purposes.
WebLogic has several benefits over Tomcat, in that it supports distributed transactions using transaction managers, supports Enterprise Java Beans, and offers other functionalities that make it a good choice for commercial and enterprise applications. In addition, WebLogic comes with a great administration console that makes the management of the server a seamless process.
|Tomcat Benefits||WebLogic Benefits|
|Open source||Developed by Oracle Corporation|
|Quick start and redeploys||Supports Enterprise Java Beans (EJB)|
|Can be used freely for commercial projects<||Transactions management|
If your application requires most or all the features of Java EE and you need commercial support, WebLogic is the way to go. Be warned, however, it's not free.
Tomcat vs. JBoss / Wildfly
Another application server that implements full Java EE specification is JBoss AS. Developed by Red Hat, JBoss Application Server is an open source platform that offers a rich feature set and is available for all the platforms where Java is available. For those confused about the name, JBoss AS was renamed to WildFly, which is the community version of the application server that has a Java EE8 certification.
Red Hat doesn’t provide support for the community project for WildFly. But, due to its popularity, there are many tutorials on the web — as well as the big userbase on StackOverflow. If your main goal is to use JBoss in the production environment, you may consider subscribing to Red Hat as it is the only way how to get support. The commercially supported product is called JBoss EAP and it is actually derived from the WildFly community project.
|Tomcat Benefits||JBoss EAP / WildFly Benefits|
|Open source||Full Java EE application server for free (WildFly)|
|Quick start and redeploys||Commercial support (JBoss EAP|
|Java EE 8 certified|
Choosing the right application server can be a tough decision for Java development teams. But one thing is clear, you always need to consider the needs of the application. This will prevent a situation where you would choose a tool that offers more than the application needs, adding unwanted load to everything else – memory, startup times, and configuration.
If you are not sure what server is good for you, you can start with Tomcat and see if it is enough. As you saw above, the installation and deployment take a matter of minutes.
While Apache Tomcat is not really a “pure” application server, comparing it with the other tools mentioned above should give you insight into how each tool should be applied. For lightweight tools, the main competitor for Tomcat is Jetty, as both implement just some features from Java EE. If you require enterprise support, then you should consider using JBoss EAP.
If you're looking for additional insight into popular Java server technologies, be sure to check out the resources below.
- Report - 2022 Java Developer Productivity Report
- Webinar - Exploring the 2022 Java Developer Productivity Report
- Video - How to Install JRebel for Tomcat in Under Five Minutes
Try JRebel for Free
Want to see how JRebel can help speed up your Java development? Start skipping redeploys today with a free JRebel trial.
Editor's Note: This blog was originally published in 2020 and was updated in March, 2022.