JSP Tutorial


            

JSP architecture

 

JSPs are built on top of SUN’s servlet technology. JSPs are essential an HTML page with special JSP tags embedded. These JSP tags can contain Java code. The JSP file extension is .jsp rather than .htm or .html. The JSP engine parses the .jsp and creates a Java servlet source file. It then compiles the source file into a class file, this is done the first time and this why the JSP is probably slower the first time it is accessed. Any time after this the special compiled servlet is executed and is therefore returns faster.

 

 

Steps required for a JSP request:

  1. The user goes to a web site made using JSP. The user goes to a JSP page (ending with .jsp). The web browser makes the request via the Internet.
  2. The JSP request gets sent to the Web server.
  3. The Web server recognises that the file required is special (.jsp), therefore passes the JSP file to the JSP Servlet Engine.
  4. If the JSP file has been called the first time, the JSP file is parsed, otherwise go to step 7.
  5. The next step is to generate a special Servlet from the JSP file. All the HTML required is converted to println statements.
  6. The Servlet source code is compiled into a class.
  7. The Servlet is instantiated, calling the init and service methods.
  8. HTML from the Servlet output is sent via the Internet.
  9. HTML results are displayed on the user’s web browser.