Java EE notebook
  • Introduction
  • /web-customer-tracker
  • Web Service
  • AOP
  • Web Server2(Spring REST)
  • Security
  • Json
  • Web Server VS Application Server VS Web Containers
  • different between Servlet & JSP2
  • DI
  • 0
  • 1annotation inversion of control, bean scope
  • 2 annotation dependency injection
  • 3 annotation bean scope, java code config
  • 4 Spring MVC
  • rest web services
  • Spring-Hibernate0
  • Spring-Hibernate1
  • @ManyToMany
  • spring mvc work flow
  • Spring Security
  • JWT
  • @Autowired
  • Jersey REST Service
  • Spring Bean
Powered by GitBook
On this page

Was this helpful?

Web Server VS Application Server VS Web Containers

PreviousJsonNextdifferent between Servlet & JSP2

Last updated 5 years ago

Was this helpful?

Typically, a Web server refers to an execution infrastructure that handles HTTP requests and responses; a servlet container refers to a component that handles the lifecycle for servlets; an application server refers to a framework (servlet container, EJB container, JSP engine, MQ container, etc.) for handling Web applications. However, a Web container has a couple of meanings depending on the source. Most refer to a Web container as the part of an application server that manages servlets, JavaServer Pages (JSP) files, and other Web-tier components. Some refer to a Web container as the infrastructure for managing the lifecycle for Web services.

1) Examples

In order to better understand the difference, you must know some popular examples of the web server, application server, and web containers. Apache and IIS are two popular web servers. Apache is used everywhere including Java world but IIS is more popular in Microsoft ASP .NET world. From Java EE perspective couple of popular application servers are IBM WebSphere, Oracle WebLogic, Glassfish and Redhat's JBoss. Coming back to web containers or servlet engines, and are two of the most popular Servlet engine in Java web world.

2) Features and Responsibility

The significant difference between web server and application server comes from a responsibility perspective. Web servers are responsible for serving static content e.g. HTML over HTTP protocol while application server is responsible for serving dynamic content, managing EJB pool, facilitating distributed transaction, facilitating application lookup over JNDI, application security and others. While web containers are only responsible for generating HTML by executing JSP and Servlet on Server side.

3) Service

One more difference between an application server and web server comes from the service perspective. It's expected from a Web server to provide HTTP protocol level service while application server is supposed to provide more powerful and dynamic Web service and business level service via EJB (Enterprise Java Beans). Essential services like Database connection pooling is not only provided by application server but also by Web containers like Tomcat. You can read more about how to setup connection pool in tomcat .

4) Usage

Once you know the difference between web and application server and web containers, it's easy to figure out when to use them. You need a web server like Apache HTTPD if you are serving static web pages. If you have a Java application with just and to generate dynamic content then you need web containers like Tomcat or Jetty. While, if you have Java EE application using EJB, distributed transaction, messaging and other fancy features than you need a full fledged application server like JBoss, WebSphere or Oracle's WebLogic.

Apache Tomcat
Jetty
here
JSP
Servlet