WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

JSP client request


The web server needs a JSP engine, which is a container to handle JSP pages. The container is responsible for intercepting requests for JSP pages. This tutorial uses Apache with an embedded JSP container to support JSP Development.

The JSP container works in conjunction with the Web server to provide the necessary runtime and other services for the proper operation of the JSP and to properly identify the specific elements that are specific to the JSP page.

The image below shows where the JSP container and JSP files are located in the web app.

JSP processing

The following steps show how a web server uses JSP to create a web page:

  • Like other normal web pages, your browser sends an HTTP request to the server.

  • The web server recognizes that this is a request for a JSP web page and passes the request to the JSP engine. This is done by using a URL or a .jsp file.

  • The JSP engine loads JSP files from disk and converts them into servlets. This conversion simply replaces all template text with the println() statement and converts all JSP elements into Java code.

  • The JSP engine compiles the servlet into an executable class and passes the original request to the servlet engine.

  • A component of the web server will call the servlet engine and then load and execute the servlet class. During execution, the servlet produces an HTML-formatted output and embeds it in an HTTP response for delivery to the web server.

  • The web server returns the HTTP response to your browser as a static HTML page.

  • In the end, a web browser handles dynamically generated HTML pages in an HTTP response as if it were a static web page.

The steps mentioned above can be represented by the following figure:

In general, the JSP engine checks if the servlet corresponding to the JSP file already exists and checks if the modification date of the JSP file is earlier than the servlet. If the modification date of the JSP file is earlier than the corresponding servlet, then the container can determine that the JSP file has not been modified and the servlet is valid. This makes the entire process faster and faster than other scripting languages such as PHP.

In general, JSP pages are another way to write servlets without becoming a Java programming expert. In addition to the interpretation phase, JSP pages can be treated almost as a normal servlet.