How JSP Works

JavaServer Pages are made operable by having their contents (HTML tags, JSP tags and scripts) translated into a servlet by the application server.

JSPLifeCycle1stJT_wm

  1. A request is sent to the JSP page from web browser.
  2. The content of the JSP file is parsed by the JSP engine.
  3. The JSP engine translates the JSP to  a servlet java file based on the content of the JSP. The generated servlet is responsible for rendering the static elements of the JSP specified at design time in addition to creating the dynamic elements of the page.
  4. The servlet java file is compiled by the Java compiler into a servlet class file.
  5. The servlet is instantiated. The init and service methods of the servlet are called, and the servlet logic is executed.
  6. The static HTML, graphics and dynamic elements specified in the original JSP page definition are sent to the Web browser through the output stream of the servlet’s response object.

Prerequisites

We assume that you already have some knowledge in java fundamentals  Java Fundamentals

Setup working environment Create new Dynamic Web Project with Eclipse IDE