The Anatomy of a JSP Page
A JSP page is simply a regular web page with JSP elements for generating the parts of the page that differ for each request, as shown in Figure 3.2.
Everything in the page that is not a JSP element is called template text . Template text can really be any text: HTML, WML, XML, or even plain text. Since HTML is by far the most common web page language in use today, most of the descriptions and examples in this book are HTML-based, but keep in mind that JSP has no dependency on HTML; it can be used with any markup language. Template text is always passed straight through to the browser.
Figure 3-2. Template text and JSP elements
When a JSP page request is processed, the template text and the dynamic content generated by the JSP elements are merged, and the result is sent as the response to the browser.
JSP Elements
There are three types of elements with JavaServer Pages: directive, action, and scripting elements.
The directive elements, shown in Table 3.1, are used to specify information about the page itself that remains the same between page requests, for example, the scripting language used in the page, whether session tracking is required, and the name of a page that should be used to report errors, if any.
Table 3-1. Directive Elements
Element |
Description |
---|---|
<%@ page ... %> |
Defines page-dependent attributes, such as scripting language, error page, and buffering ... |
Get Java Server Pages now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.