JSP Architecture

Last Updated : 14 May, 2026

JSP (JavaServer Pages) architecture is based on a request-response model, where a client sends a request to the web server, and the server processes it using JSP. Internally, the JSP file is converted into a Servlet, compiled, and executed to generate a dynamic response (HTML) that is sent back to the client.

  • Follows client-server architecture using HTTP request and response
  • Works with Servlets, JavaBeans, and MVC pattern for dynamic web applications

Architecture of JSP

JSP follows a Servlet-based architecture where a JSP page is translated into a servlet, compiled, and executed on the server to generate dynamic responses.

client

Below diagram explanation step-by-step working of JSP.

jsp

Working of a JSP file

  • Client Request – The browser sends an HTTP request for a .jsp file to the web server.
  • JSP File Identification – The server identifies that the requested file is a JSP page and forwards it to the JSP engine.
  • Check for Compilation – The server checks whether the JSP is already compiled into a servlet. If yes, it uses the existing one; otherwise, it proceeds further.
  • Translation Phase – The JSP engine converts the JSP file into an equivalent Java Servlet source code.
  • Compilation Phase – The generated servlet code is compiled into a .class file.
  • Initialization – The servlet is loaded and initialized by calling the init() method (only once).
  • Execution (Service Method) – For each request, the servlet’s service() method is called to process the request and generate dynamic content (HTML).
  • Response Generation – The servlet prepares the response and sends it back to the web server.
  • Display in Browser – The web server sends the response to the browser, and the final webpage is displayed.

Advantages of JSP

  • Easy to develop: Allows mixing of HTML with Java, making it simple to create dynamic web pages
  • Reusable components: Supports JavaBeans and custom tags for code reuse
  • Better performance: JSP is compiled into a Servlet, so execution is fast after first request
  • Separation of concerns: Works with MVC (Servlets handle logic, JSP handles view)
  • Platform independent: Runs on any server that supports Java (like Tomcat)
  • Automatic recompilation: Changes in JSP are automatically detected and recompiled
Comment