How JavaServer Pages work

JSP pages are executed in a JSP engine (also called a JSP container) that is installed on a Web or application server. The JSP engine receives a request from a client and delivers it to the JSP page. The JSP page can create or use other objects to create a response. For example, it can forward the request to a servlet or an EJB component, which processes the request and returns a response to the JSP page. The response is formatted according to the template in the JSP page and returned to the client.

Translating into a servlet class

In PowerBuilder, JSP pages are deployed to the server in source form. If a JSP page is in source form, the JSP engine typically translates the page into a class that implements the servlet interface and stores it in the server’s memory. Depending on the implementation of the JSP engine, translation can occur at any time between initial deployment and the receipt of the first request. As long as the JSP page remains unchanged, subsequent requests reuse the servlet class, reducing the time required for those requests.

Requests and responses

Some JSP engines can handle requests and responses that use several different protocols, but all JSP engines can handle HTTP requests and responses. The JspPage and HttpJspPage classes in the javax.servlet.jsp package define the interface for the compiled JSP, which has three methods: