JSP Architecture

Java Server Pages are slightly different from HTML pages because JSP pages contains Java Code inside them.

In this chapter we will see JSP Architecture. As you all know JSP is a server side technology where code is executed at server side.

I hope you’ve learn how to run JSP application on Tomcat Server. Basically Tomcat contains JSP engine which is responsible to execute JSP application.

Similarly, we need JSP engine and some other components to execute our JSP application.

Let’s understand.


JSP Processing:

  1. Web Browser sends a request in the form of HTML or JSP page to the server.
  2. The web server recognize the coming request by looking at (.html) or (.jsp) extension.
  3. JSP page is forwarded to JSP Engine.
  4. JSP page is converted into the Servlet and generate the Java code (.java)
  5. Java code is compiled to (.class)
  6. Compiled code is forwarded to JSP container and executes it.
  7. After execution, the request is sent back to the client browser.

Typically, to make JSP more efficient and faster, before executing any JSP page, JSP Engine checks whether a servlet for incoming JSP request exists in the container or not. If yes then no new processing will be held in the container.

IMPORTANT: JSP Container(Engine) has two different engines – called Catalina and Jasper. For example Tomcat Server.

Catalina is a Servlet Engine and Jasper is a JSP Engine.

Afterall JSP is converted to Servlet, then

  1. Why we are writing JSP pages?
  2. Why we are not learning Servlet only?

I would say, Java server pages are extension to Servlet because we don’t need to take care of complex Java Code and there is no need to insert HTML into Java code, that looks confusing and hard to learn.

Here, JSP architecture very well defines how you can easily integrate Java and HTML and run on server as like Servlets and all is taken care by JSP Engine.

I hope you’ve understood JSP Architecture and it’s working.

Leave a Comment