Web Containers and Servlet Contexts

The WAR file is deployed to what’s called a web container. A web container provides the runtime environment for a Java web application. For instance, it translates request and response data between the raw protocol format and the Java object representations the web application works with and maintains shared resources (such as database connection pools and logfiles). All web containers provide tools for installing a WAR file, or a special directory where a WAR file is automatically picked up (such as the webapps directory in Tomcat). Most containers also support web applications deployed directly in a filesystem using the same file structure as is defined for the WAR file, which can be convenient during development.

There are many different types of web containers. Some containers are called add-ons, or plug-ins, and are used to add support for Java web applications to regular web servers (such as Apache and IIS). They can run in the same operating-system process as the web server or in a separate process. Other containers are standalone servers. A standalone server includes web server functionality to provide full support for HTTP in addition to the web application runtime environment. Containers can also be embedded in other servers, such as a climate-control system, to offer a web-based interface to the system. A container bundled as part of an application server typically distributes the execution over multiple hosts and can provide fail-over ...

Get JavaServer Faces now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.