What's the difference between Tomcat and Apache?
It's a question developers hear frequently. But, when worded that way, it contains some misleading assumptions.
Normally, when people ask this question, they really want to know, "What's the difference between Apache Tomcat and the Apache HTTP Server?" Note that both Apache Tomcat and the Apache HTTP Server are projects maintained by the Apache Software Foundation. When you consider that important detail, it's easier to recognize the ill-worded nature of the original Tomcat vs. Apache question.
The confusion largely stems from the fact that the term Apache has become the colloquial name for the Apache HTTP Server. Released in 1995, the Apache HTTP Server (AHS) was the first Apache project and predates the establishment of the Apache Software Foundation in 1999. For the longest time, the term Apache and the Apache web server were synonymous with each other, which resulted in the confusion we now face.
Tomcat and AHS differences
Purpose is the fundamental difference between Tomcat and the Apache web server.
The purpose of the Apache HTTP Server is to simply serve static files such as text, HTML, images, audio and video files to web-based clients. In contrast, the Apache Tomcat server delivers content that changes depending upon who the client is, whether the client has signed in and what the client has done on previous interactions with the server.
Tomcat and Apache HTTP Server prerequisites
The Apache HTTP Server has no prerequisites. It can be installed on any computer that runs a modern edition of Windows, a Linux distribution or Unix.
Tomcat, however, requires a JDK installation, along with a properly configured JAVA_HOME environment variable. The dynamic nature of Apache Tomcat comes from logic implemented in Java code form that is written and deployed to it.
Tomcat vs. Apache web server architecture
Modern software architectures embrace a three-tiered approach to content delivery.
The first is known as the client or presentation tier. The Apache HTTP Server resides on this client tier. It is the first server-side resource a client interacts with when a request is made, and sends a final response back to the client.
If a request is for a simple, static file such as HTML or an image, the Apache web server will send that file back to the client. If the request requires some logic, the Apache web server passes the request to the Tomcat server. As such, the Tomcat server is considered to be part of the middle-tier of a modern software architecture topology.
If a request requires it to perform logic, a Tomcat server may need to interact with a relational database, a NoSQL datastore or even a message queue. These resources are said to be part of the back-end tier -- or the third tier -- in a modern architecture.
So the typical request flow in a three-tier architecture is to first hit the Apache web server, followed by the middle-tier Tomcat server and then Tomcat interacts with databases and other resources in the back-end tier. Tomcat aggregates the results and passes them to the Apache HTTP Server, and the HTTP server then sends the final response back to the client.
|Tomcat vs. Apache web server: The key differences
|Apache HTTP Server
|Apache License 2.0
|Apache License 2.0
|Nginx, Lighttpd, Microsoft IIS
|JBoss, Jetty, Payara, Wildfly, WebSphere Liberty
|modern Linux or Windows operating system
|a local JDK installation
|any individual file
|WAR and JAR files
|adult male cat
|Default HTTP port
Tomcat vs. Apache web server deployment
The Apache web server has a special folder named \htdocs. Resources placed under this folder become accessible to incoming requests. With this folder, when you deploy files to the Apache HTTP Server, it's as simple as moving files -- either by copying or using FTP -- to the \htdocs folder or any of its subfolders.
In contrast, applications deployed to the Tomcat server must be packaged as web application archives or .war files. The format of these .war files, along with the deployment descriptors they must contain, are rigidly defined by the Servlet and JSP API.
Tomcat implements Java EL and the Java WebSocket API along with its spot as a reference implementation of the Servlet and JSP API.
Tomcat and Apache HTTP Server enhancements
Despite the fact that Apache HTTP Server deals with static content, it is possible for it to deliver dynamic content if you install various modules or extensions, such as Perl, Python and PHP add-ons.
There are also extensions to the Apache Tomcat server that allow for the implementation of specifications other than the Servlet and JSP API. For example, Apache TomEE builds on top of Tomcat to support EJB and JAX-RS specifications.
Tomcat and Apache HTTP Server competitors
The Apache HTTP Server's biggest competitor is the popular Nginx HTTP server. The Node.js runtime environment, Lighttpd and the Microsoft Internet Information Services server are other popular Apache HTTP Server alternatives.
Key difference between Tomcat and the Apache HTTP Server
There are many ways to compare Tomcat vs. the Apache HTTP Server, but the fundamental difference is that Tomcat provides dynamic content by employing Java-based logic, while the Apache web server's primary purpose is to simply serve up static content such as HTML, images, audio and text.