It is essential to know the JSP engine and the entire architecture. This will make you understand better how the internal working of the JSP takes place. The JSP architecture is a 3-tier architecture where each part has its own roles and functionalities. This chapter describes the JSP architecture and how the webserver processes JSP pages.
The JSP-based web application needs a JSP engine, which is a Web container. A Web container can be defined as a web server component that helps in executing Web programs like servlet, ASP, etc. The JSP container intercepts the JSP page requests.
JSP Architecture Flow (How JSP Pages are Processed?)
- When a user navigates to a page ending with a .jsp extension in their web browser, the web browser sends an HTTP request to the webserver.
- The webserver checks if a compiled version of the JSP page already exists.
- If the JSP page's compiled version does not exist, the file is sent to the JSP Servlet engine, it converts it into servlet content (with .java extension). This process is known as translation.
- Then after translated .java file of the servlet is compiled into the Java servlet .class file. This process is known as compilation.
- In the last step, the compiled .class file of the servlet is executed, and the result (HTML) is sent back to the client machine as an HTTP response.