3. JavaServer Page Architecure

Objective

The objective of this section is to provide an overview of the JSP architecture and also the software required for JavaServer Pages.

Application Architecture

As we read earlier JavaServer Pages is a server side technology that dynamically produces web pages. It is an important to note that when a JavaServer Page executes the result that is sent to the browser is just the HTML and not the Java code.

The output of a JSP doesn't have to be HTML - it can be any text stream. So explicitly when a JSP executes the Java code is executed and the result of that execution is sent to the browser. It is up to the browser to deal with that output. There are scenarios where you may want to produce an output that isn't HTML, for example, XML or plain text.

The diagram below illustrates the components involved in JSP and the information flow between them. Click on the image to display a bigger image. Note, this website doesn't use popup windows however if you wish to view the larger image in a new window then, depending on your browser, either hold the Shift or Ctrl key while clicking on the image to display the larger image in a new window.

Small architecture diagram

At the highest level we have a typical web application architecture with the client sending HTTP Requests to the server which sends back HTTP Responses. What is also immediately apparent from the diagram is that the majority of the work is being done on the server. So this is where we are going to focus.

The first component to receive the client's request is the web server. The web server checks the extension of the requested file and if it is a JSP it passes the HTTP request on to the Application Server. If it isn't a JSP then the web server serves up the requested web page. Note, most web servers need to be configured to recognise a JSP extension.

The Application Server is the component that processes, compiles and executes JavaServer Pages. The output of the JSP execution is passed back to the web server which, in turn, sends the result to the browser.

Summary

The next section looks in more detail to the JSP structure and what happens when the page is compiled to a Servlet and is executed.

Back Next