Download FAQ History |  | API Search Feedback

> ## Setting Properties for Groups of JSP Pages

> It is possible to specify certain properties for a group of JSP pages:

> - Expression language evaluation
> - Treatment of scripting elements (see Disabling Scripting)
> - Page encoding
> - Automatic prelude and coda includes

> A JSP property group is defined by naming the group and specifying one or more URL patterns; all the properties in the group apply to the resources that match any of the URL patterns. If a resource matches URL patterns in more than one group, the pattern that is most specific applies., you add the `jsp-property-group` element within a `jsp-config` element to the Web application deployment descriptor (see Example). The following sections discuss the properties and how they are interpreted for various combinations of group properties, individual page directives, and Web application deployment descriptor version.

> #### Deactivating EL Evaluation

> Each JSP page has a default mode for EL expression evaluation. The default value varies depending on the version of the Web application deployment descriptor. The default mode for JSP pages delivered using a Servlet 2.3 or earlier descriptor is to ignore EL expressions; this provides backwards compatibility. The default mode for JSP pages delivered with a Servlet 2.4 descriptor is to evaluated EL expressions; this automatically provides the default that most applications want. For tag files (see Encapsulating Reusable Content using Tag Files), the default is to always evaluate expressions.

> You can override the default mode through the `isELIgnored` attribute of the `page` directive in JSP pages and the `isELIgnored` attribute of the `tag` directive in tag files. The default mode can also be explicitly changed by adding the `el-ignored` element within a `jsp-property-group` element to the Web application deployment descriptor. Table 16-5 summarizes the EL evaluation settings for JSP pages and their meanings:

> Table 16-5 EL Evaluation Settings for JSP Pages
> JSP Configuration | Page Directive isELIgnored | EL Encountered
> --- | --- | ---
> Unspecified | Unspecified | Evaluated if 2.4 `web.xml` Ignored if <= 2.3 `web.xml`
> `false` | Unspecified | Evaluated
> `true` | Unspecified | Ignored
> Overridden by page directive | `false` | Evaluated
> Overridden by page directive | `true` | Ignored

> Table 16-6 summarizes the EL evaluation settings for tag files and their meanings:

> Table 16-6 EL Evaluation Settings for Tag Files
> Tag Directive isELIgnored | EL Encountered
> --- | ---
> Unspecified | Evaluated
> `false` | Evaluated
> `true` | Ignored

> #### Declaring Page Encodings

> You set the page encoding of a group of JSP pages by adding the `page-encoding` element within a `jsp-property-group` element to the Web application deployment descriptor. Valid values are the same as the `pageEncoding` attribute of the `page` directive. A translation-time error results if you define the page encoding of a JSP page with one value in the JSP configuration element and then give it a different value in a `pageEncoding` directive.

> #### Defining Implicit Includes

> You can implicitly include preludes and codas for a group of JSP pages by adding `include-prelude` and `include-coda` elements respectively within a `jsp-property-group` element to the Web application deployment descriptor. Their values are context-relative paths that must correspond to elements in the Web application. When the elements are present, the given paths are automatically included (as in an `include` directive) at the beginning and end of each JSP page in the property group respectively. When there is more than one include or coda element in a group, they are included in the order they appear. When more than one JSP property group applies to a JSP page, the corresponding elements will be processed in the same order as they appear in the JSP configuration section.

> For example, the Duke's Bookstore uses the files `/template/prelude.jspf` and `/template/coda.jspf` to include the banner and other boilerplate in each screen. Preludes and codas can only put the included code at the beginning and end of each file. For a more flexible approach to building pages out of content chunks, see A Template Tag Library.

> #### Example

> The following JSP configuration element from Duke's Bookstore declares all files named `/*.jsp` are in a property group named `bookstore2`. It specifies that the EL should not be ignored, that scripting is valid, that none of the pages are in XML syntax, and declares prelude and coda files.

>     <jsp-config>
>       <jsp-property-group>
>         <display-name>bookstore2</display-name>
>         <url-pattern>/*.jsp</url-pattern>
>         <el-ignored>false</el-ignored>
>         <scripting-invalid>false</scripting-invalid>
>         <is-xml>false</is-xml>
>         <include-prelude>/template/prelude.jspf</include-prelude>
>         <include-coda>/template/coda.jspf</include-coda>
>       </jsp-property-group>
>     </jsp-config>

Download FAQ History |  | API Search Feedback

All of the material in The Java(TM) Web Services Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.