JSP at GlassFish
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/htmlfor JSP pages in standard syntax andtext/xmlfor 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 astext/xhtml, for the whole application.The MR adds a JSP configuration element
default-content-typeto thejsp-property-groupelement. It can be used to set the default content type for a group of JSP pages that matches the URL pattern defined in thejsp-property-group.Set Default Buffer Size
Likewise, the MR adds a JSP configuration element
bufferto thejsp-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 thejsp-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-namespaceelement to thejsp-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 thejsp-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
omitto<jsp:attribute>. When it evaluates totrue, 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>Whenwidthis "100", for instance, the following is generated:<image width="100"> body </image>Whenwidthis 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.
Posted at 04:54PM Feb 03, 2009 by kchung in Personal |