What is Tomcat? Is it a Web
Server? What can Tomcat do? How is it different than Apache Web Server?
As
it was a bit confusing for me, I made a small research on these and wanted to
share some notes here.
In general, the Apache
HTTP server is just a plain old web server designed to serve static web pages. There are plenty of modules which can be installed to
enhance Apache's abilities so that it
can serve dynamic webpages using various technologies such as PHP, CGI or
whatever, but the core of Apache is just a plain old HTTP server.
I
think rest of the answer is not very clear, the part explaining what Tomcat
actually is so let's move on to some other resources..
Even the question itself
starts with good information:
I
know that Tomcat is written in Java and the HTTP Server is in C, but other
than that I do not really know how they are distinguished. Do they have
different functionality?
And a comment in the
accepted answer gives us a lot of nice information:
Tomcat does indeed bring
with it a capable web server. Tomcat is a Servlet/JSP container and also offers
a web server. Tomcat's web server is quite good, able to handle most small and
medium web site needs. With support for Java NIO and 64-bit memory, even some
larger scale web sites may be served well by Tomcat's Catalina module. For
various reasons, some folks choose to ignore Coyote and instead use Tomcat's
Servlet capabilities behind the Apache httpd web server product.
Tomcat = ( Web Server +
Servlet container + JSP environment ). The web server is ON by default when you
run Tomcat’s startup.sh script, listening on port 8080 for incoming connections
(HTTP calls). Tomcat is pure Java, with its own web server implementation
(Coyote). The Apache HTTP Server (AHS), in contrast, has a completely separate
implementation of a web server, using native C/C++ code. AHS is very flexible
and powerful, but is often overkill. Tomcat's own web server works very well.
Use AHS only if truly needed. This gives us the hint that Tomcat actually
is a collection of a few modules.
Components
Tomcat
4.x was released with Catalina (a servlet container), Coyote (an HTTP
connector) and Jasper (a JSP engine).
Catalina
Catalina
is Tomcat's servlet container. Catalina implements Sun Microsystems'
specifications for servlet and JavaServer Pages (JSP). In Tomcat, a Realm
element represents a "database" of usernames, passwords, and roles
(similar to Unix groups) assigned to those users.Different implementations
of Realm allow Catalina to be integrated into environments where such
authentication information is already being created and maintained, and then
use that information to implement Container Managed Security as described in
the Servlet Specification.
Coyote
Coyote
is a Connector component for Tomcat that supports the HTTP 1.1 protocol as a
web server. This allows Catalina, nominally a Java Servlet or JSP container, to
also act as a plain web server that serves local files as HTTP documents.
Coyote
listens for incoming connections to the server on a specific TCP port and
forwards the request to the Tomcat Engine to process the request and send back
a response to the requesting client. Another Coyote Connector, Coyote JK,
listens similarly but instead forwards its requests to another web server, such
as Apache, using the JK protocol.This usually offers better performance.
Jasper
Jasper
is Tomcat's JSP Engine. Jasper parses JSP files to compile them into Java code
as servlets (that can be handled by Catalina). At runtime, Jasper detects
changes to JSP files and recompiles them.
The information I find here
particularly important is:
Apache Tomcat and Apache
HTTP are completely different server technologies. It is impossible to use a
plugin for Apache HTTP server with Tomcat.
Apache HTTP server is developed in C and so are the plug-ins. On the contrary
Tomcat is now completely developed in Java. Tomcat doesn't only serve static
content, but it can also serve JSP pages and servlets.
In
this post I tried to summarize the knowledge I have found around. This will
help me remember this information whenever I need it, and hopefully is useful
for you as well.
Apache HTTP server is developed in C and so are the plug-ins. On the contrary Tomcat is now completely developed in Java. Tomcat doesn't only serve static content, but it can also serve JSP pages and servlets.
Very good & informative information.
ReplyDelete