Easy Tutorial
❮ Jsp Handling Date Jstl Format Setbundle Tag ❯

JSP Structure

A web server requires a JSP engine, also known as a container, to process JSP pages. The container is responsible for intercepting requests to JSP pages. This tutorial uses Apache with an embedded JSP container to support JSP development.

The JSP container works in collaboration with the web server to provide the necessary runtime environment and other services for the normal operation of JSP, and it can correctly recognize special elements unique to JSP pages.

The diagram below shows the position of the JSP container and JSP files in the web application.


JSP Processing

The following steps illustrate how a web server uses JSP to create web pages:

-

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

-

The web server recognizes this as a request for a JSP page and forwards the request to the JSP engine. This is done using a URL or a .jsp file.

-

The JSP engine loads the JSP file from disk and converts it into a Servlet. This conversion involves replacing all template text with println() statements and converting all JSP elements into Java code.

-

The JSP engine compiles the Servlet into an executable class and forwards the original request to the Servlet engine.

-

A component of the web server calls the Servlet engine, which loads and executes the Servlet class. During execution, the Servlet generates HTML output and embeds it in an HTTP response, which is then sent to the web server.

-

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

-

Finally, the web browser processes the dynamically generated HTML page in the HTTP response as if it were a static page.

The steps mentioned above can be represented in the diagram below:

Typically, the JSP engine checks if the Servlet corresponding to the JSP file exists and if the modification date of the JSP file is earlier than that of the Servlet. If the JSP file's modification date is earlier than the Servlet's, the container can determine that the JSP file has not been modified and the Servlet is valid. This makes the process more efficient and faster compared to other scripting languages like PHP.

In summary, a JSP page is a way to write a Servlet without needing to be a Java programming expert. Apart from the interpretation phase, a JSP page can be treated almost like a regular Servlet.

❮ Jsp Handling Date Jstl Format Setbundle Tag ❯