Sitemap
Seshumadhav

Seshumadhav

Servers (Web, application, JSP etc.,)

3 min readSep 6, 2016

Web server is a program that runs on a server platform. It takes the URL sent by the client(browser), finds a file on a server that it can send back to the client, as an HTTP response. Eg: Apache. Web servers can serve only the static contents like HTML files and images.

But content that client wants need not always be static; Clients require dynamic content or content based on their input. To serve dynamic content, we have this concept called Application Servers. WebServer can forward the request to some other applications in case of any requests for dynamic content.

Application server is an application, which provides a set of components accessible to the software developer through an API. Eg. JBoss

In a typical web application,

  1. the web server first receives the request from client.
  2. If the request is for any static files, web server can return that file as the response.
  3. If it is for a dynamic content, then the request will be forwarded to the application server which can return the dynamic contents.
Press enter or click to view image in full size

ServletEngine / ServletContainer facilitates Java Servlets to serve the requests from clients. It manages the life-cycle of Servlets, map any valid URL to Servlets and ensure the access privileges of Servlets. In simple terms, it is a program that takes a client request for a dynamic page => activates a Java class — the servlet — that provides the dynamic content. The content is typically derived from DB as well. Eg: Tomcat. Hence it should be clear that, A servlet engine is almost always separate architecturally from the Web server.

NOTE1: All Application servers contain a built in ServletEngine to handle the Servlets and JSPs. Eg: JBoss

NOTE2: But, there are some servers that are not (Java EE) Application Servers, but simply a combination of WebServer + ServletEngine. Eg: Tomcat, Jetty

Get Seshumadhav’s stories in your inbox

Join Medium for free to get updates from this writer.

eg: Architecture of Tomcat

Press enter or click to view image in full size

JSP Container / JSP Engine: JSP Component is a type of Java servlets, which are more convenient to write (and to modify!) regular HTML than to have plenty of println statements that generate the HTML. One needs a special pre-processor to convert a JSP into a Servlet, and that is called JSP Container or the JSPEngine.

  1. Browser sends an HTTP request to the web server.
  2. The web server recognizes that the HTTP request is for a JSP page and forwards it to a JSP engine.
  3. The JSP engine (a) loads the JSP page from disk and converts it into a Java servlet (b) compiles the servlet into an executable class and © forwards the original request + servlet class Servlet Engine.
  4. The servlet engine loads the servlet class and executes it. During execution, the servlet produces an output in HTML format, which the servlet engine passes to the web server inside an HTTP response.
  5. The web server forwards the HTTP response to your browser.

REFERENCES

--

--