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.
- Web Browser sends a request in the form of HTML or JSP page to the server.
- The web server recognize the coming request by looking at (.html) or (.jsp) extension.
- JSP page is forwarded to JSP Engine.
- JSP page is converted into the Servlet and generate the Java code (.java)
- Java code is compiled to (.class)
- Compiled code is forwarded to JSP container and executes it.
- 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
- Why we are writing JSP pages?
- 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.