JSP Architecture
JSP (Java Server Pages) uses a three-tier architecture with a client, web server, and database. When the client sends a request, the web server's JSP engine processes the JSP file by converting it into a servlet, compiling, and executing it. The generated HTML is sent back to the client. The following diagram shows the architecture of JSP.
Architecture of JSP:

JSP (JavaServer Pages): It is a server-side technology used to create dynamic, platform-independent web applications. It allows embedding Java code directly into HTML or XML using JSP tags. When a client sends a request, the JSP file is first converted into a servlet by the JSP container, then compiled and executed.
Below diagram explanation step-by-step working of JSP.

Working of a JSP file
- When a user accesses a webpage with a .jsp extension, the browser sends an HTTP request to the web server for that JSP file.
- The web server checks if a compiled version of the JSP already exists. If it does, it uses that. If not, the request is passed to the JSP engine for processing.
- The JSP engine reads the JSP file and translates it into a Java Servlet by converting the HTML and JSP code into equivalent Java code.
- This Java Servlet is then compiled into a .class file (bytecode) that the server can execute.
- The servlet runs on the server, generates dynamic content (usually HTML), and prepares it as a response.
- Finally, the web server sends this generated HTML back to the user’s browser, which displays the resulting webpage.