36

I currently have Apache httpd running on a production Ubuntu VPS server. I write php scripts.

I'm interested in learning Java and I was wondering how I would go about writing some server-side Java to work on my current set-up.

How are Apache Tomcat and Apache HTTP Server related to each other?

Can Tomcat be a module of httpd?

Or are they simply just two very different projects that happen to be steered by the same organisation (Apache Software Foundation)?

codeforester
  • 105
  • 1
  • 1
  • 6
JW01
  • 3,579
  • 4
  • 22
  • 22

1 Answers1

58

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.

Tomcat, on the other hand, is specifically designed from the ground-up to serve as a Java Servlet engine. It's primary purpose is to implement the Java Servlet API and execute Java servlets for the purpose of building dynamic websites. Tomcat can also be used as a regular HTTP server that serves static pages, but that is not its primary purpose. (Also, Tomcat is allegedly slower than Apache httpd when it comes to serving static pages.)

The two technologies can be used together through a connector module called mod_jk. This will allow you to use the Apache HTTP server to serve regular static webpages, and the Tomcat Servlet engine to execute servlets.

Charles Salvia
  • 7,342
  • 1
  • 35
  • 33
  • Can we say that when one downloads Tomcat s/he downloads a Web Server like Apache Httpd (but not exactly this) AND a Servlet Container which is simply a java application? – Koray Tugay Nov 25 '14 at 18:22
  • @Charles, Why is Tomcat slower than Apache? – Pacerier Jan 19 '15 at 06:48
  • @Pacerier - he said "allegedly", because while people widely believe this, [in reality it isn't true](http://www.tomcatexpert.com/blog/2010/03/24/myth-or-truth-one-should-always-use-apache-httpd-front-apache-tomcat-improve-perform). – Jules May 02 '16 at 07:07
  • @KorayTugay not exactly, no. Tomcat is *just* a servlet container. It happens to come supplied with a default servlet that implements a static web server. You couldn't separate out the web server component without the servlet container. – Jules May 02 '16 at 07:15