3

I've been using Tomcat and Jetty for quite some time now. From what I know. an application server(Servlet Container) is a container for your servlets. while the http server handles Http request and responses. but all the time I feel abstracted how these two works.

Can someone give me a high level overview of how Http Server and Application Server works? because I was reading . Grizzly and it is a NIO Server. so is it an HTTP Server? or an Application Server?

user962206
  • 15,637
  • 61
  • 177
  • 270
  • I great answer can be found here http://www.theserverside.com/feature/Understanding-How-the-Application-Servers-Web-Container-Works, on *From Web Server to Application Server* section. – giannis christofakis Apr 23 '15 at 11:47

1 Answers1

3

HTTP server is a component mainly concerned with handling of HTTP requests and providing HTTP responses to a client. Of course, there are other functions of an HTTP server, e.g. request forwarding, error handling and so on, but for the higher-level view it's enough to understand that an HTTP server implements the request/response mechanism. It is not tied to any programming language implementation.

Servlet container is a component that implements the Servlet specification of Java. Servlets are mainly implemented using the Java language. They are like HTTP servers in that they handle requests and responses (note that these requests and responses are higher abstractions compared to HTTP requests and responses), filters them, chain them and so on.

In most cases, servlet containers are placed behind an HTTP server. The HTTP server forwards the HTTP requests (depending on some URL mapping rules) to the servlet containers. One of the implementation of the highly-abstracted request/response specification in servlets is the HTTP request/response. In this way, an HTTP server and a servlet container can work together in serving HTTP conversations for e.g. dynamic web pages.

Application server is a more complex component (usually, it encapsulates both an HTTP server and a servlet container (if it is a Java-oriented application server)). Such a component provides modules that implement some given specifications, e.g. Java EE specification implemented by JBoss Applciation Server / WildFly.

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
Andrei Nicusan
  • 4,555
  • 1
  • 23
  • 36
  • So I am guessing that Tomcat and Jetty are Application Servers? – user962206 Nov 15 '13 at 12:36
  • Tomcat is a servlet container. It implements the servlet Java specification, but not the entire Java Enterprise Edition stack. It also contains a web server. I cannot give you expert details about Jetty, but the title of their home page is "Jetty - Servlet Engine and Http Server" :) – Andrei Nicusan Nov 15 '13 at 12:40
  • Can a Servlet Container exist without any Http Server? – user962206 Nov 15 '13 at 13:27
  • That's a good question. Theoretically, it can, because the servlet uses the abstract concept of request and response. The servlet itself is an abstraction, HTTP servlet being one of its concrete implementation, but not the only one. Looking into the servlet javadocs here (http://docs.oracle.com/javaee/6/api/javax/servlet/Servlet.html) and navigating to its various implementation (as well as reading the `service` method documentation) you will see what I mean. On another hand, it's true that I never used a servlet container without a web server and I think this is the most frequent scenario. – Andrei Nicusan Nov 15 '13 at 13:32