I am inheriting a project involving a Java web app whose backend is powered by an Apache httpd/Tomcat combo. The web server is being used to serve back JS, static content, and to perform general load balancing, and Tomcat is serving back JSPs via a single WAR file.
I will be receiving access to the code base later on today or tomorrow, but wanted to try and do some research ahead of time.
My question can be summed up as: how do these two work together?
- Who first receives HTTP requests?
- How does httpd know when to forward JSP requests on to Tomcat, or to just respond to a request itself?
- How does httpd “pass” the request to, and “receive” the response from, Tomcat? Does it just “copy-n-paste” the request/response to a port Tomcat is listening on? Is there some sort of OS-level interprocess communication going on? Etc.
These are just general questions about how the technologies collaborate with each other. Thanks in advance!
Apache, almost certainly. There could be admin processes that talk directly to Tomcat, though.
From its configuration. The specifics will vary. It might, for instance, be using
mod_jkormod_jk2, in which case you’ll findJkMountdirectives in the config files, e.g.:…which tells it to pass on requests at the root of the site for files matching
*.jspto theajp13_worker, which is defined in theworkers.propertiesfile.Or it could be set up in a simple HTTP reverse-proxy arrangement. Or something else.
It depends on the configuration; it could be HTTP, it could be AJP, or it could be using some other module.
Sort of. 🙂 See the reverse-proxy link above.
Yes. AFAIK, it’s all socket-based (rather than, say, shared memory stuff), which means (amongst other things) that Tomcat and Apache need not be running on the same machine.