Tuesday Feb 03, 2009

JSR 245 MR: Part 2 - JSP

This is the second part of the update on JSP and EL specification. A previous blog covers the EL MR. This blog covers the JSP Specification MR. The details can be obtained from here. The close date for the MR is March 3, 2009. Please send comments to me.

The proposed JSP MR fixes some typos and errors, and adds some minor enhancements to JSP. This blog covers these enhancements.

  • Declare Default Content Type

    Currently, the default content type is text/html for JSP pages in standard syntax and text/xml for pages in xml syntax. This can be overridden by the use the page directives in individual JSP pages. It would be sometimes desirable to set a content type, such as text/xhtml, for the whole application.

    The MR adds a JSP configuration element default-content-type to the jsp-property-group element. It can be used to set the default content type for a group of JSP pages that matches the URL pattern defined in the jsp-property-group.

  • Set Default Buffer Size

    Likewise, the MR adds a JSP configuration element buffer to the jsp-property-group. It can be used to set the buffering model for a a group of JSP pages that matches the URL pattern defined in the jsp-property-group.

  • Raise Errors for Undeclared Namespaces

    Currently, using an unknown namespace in standard JSP syntax is silently ignored, but is an error in xml syntax. This is somewhat inconsistent, to say the least.

    Moreover, it is a common mistaken to omit the declaration of a tag library using the taglib directive before it is used in a JSP page. The end result is that the tag library is not invoked, and nothing is displayed. This often a source for confusion to page authors.

    As a remedy, we add a error-on-undeclared-namespace element to the jsp-property-group. It can be used to force an error at compile time when undeclared namespaces are used in a group of JSP pages that matches the URL pattern defined in the jsp-property-group.

  • Omit Generation of Attribute in <jsp:element>

    <jsp:element> can be used to generate dynamic tag elements on the fly, and <jsp:attribute> can be used to generate an attribute for the element. However it is currently not possible to conditionally omit the attribute. The most we can do now is to generate an attribute with a null value, but is not the same as an omitted attribute, for some browsers.

    We now introduce an optional attribute omit to <jsp:attribute>. When it evaluates to true, the attribute is not generated in the <jsp:element>. Consider the following:

        <jsp:element name="image">
            <jsp:attribute omit=${width eq null}>
                ${width}
            </jsp:attribute>
            <jsp:body>
                body
            </jsp:body>
        </jsp:element>
    
    When width is "100", for instance, the following is generated:
        <image width="100">
            body
        </image>
    
    When width is null, the following is generated:
        <image>
            body
        </image>
    

The sources for the API and implementation will be done at the jsp project and will be bundled with Glassfish V3 release.

About

kchung

Search

Top Tags
Categories
Archives
« February 2009
SunMonTueWedThuFriSat
1
2
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
       
       
Today
Bookmarks