Find JSRs
Submit this Search


Ad Banner
 
 
 
 

JSP 1.2 Errata - March 18th, 2002 (rev a)


JSP 1.2 Errata - March 21st, 2002 (rev a)


Please send feedback to mark.roth@sun.com .

The following is a list of clarifications and corrections to the JSP 1.2 final specification (dated August 27th, 2001).

This errata has been created according to the Maintenance step of the JCP process . Issues were prompted by questions from vendors, implementors and end-users; the resolutions have been discussed in a mailing list which includes all the experts in the JSP 1.3 expert group. The discussion was done under the facilitation of Mark Roth, co-lead of the JSP 1.3 specification, acting as "Maintenance Lead" for the JSP 1.2 specification. This errata includes all issues discussed up until March 21, 2002.

This errata will be posted for a 30 day public review before being declared final.

All issues will be incorporated into the JSP 1.3 specification, which, at the time of this writing, is currently being developed under JSR-152 of the JCP. It is still undecided, if there will be additional erratas or if later clarifications will be just appear in the JSP 1.3 specification.

The errata starts with a brief list of all issues. Each issue is then described in more detail and a resolution is given. All references are to the JSP 1.2 final specification.

All Issues

1. i18n: Dynamic Page Character Encoding Clarification

Detailed Issues

Issue 1

i18n: Dynamic Page Character Encoding Clarification

Given the current JSP 1.2 specification, it is not possible to define an i18n action that sets the response's charset (corresponding to one of the client's preferred locales) in a predictable manner using Response.setLocale(). For example, the JSP Standard Tag Library (JSTL) requires this capability for its i18n tags.

According to the Servlet 2.3 specification, the charset attribute for the response's Content-Type header may be set using either setLocale() or setContentType(), both of which must be called before getWriter() for the charset to affect the construction of the writer.

Unfortunately, the JSP 1.2 specification does not define what happens if the JSP contains a page directive with a contentType attribute (causing setContentType() to be called), and one or more calls to setLocale(). In this case, there is no guarantee that the charset is set the same way in two containers. Two possible interpretations are:

  • The last call to setLocale() wins. This is the case if the container calls setContentType() before processing the page.
  • The page directive's contentType attribute wins. This is the case if the container calls setContentType() just before getWriter(), after processing some or all of the page.

Resolution

JSP.2.10.1. Page Character Encoding

[This section replaces the contentType row of Table JSP.2-1 on page 52 of the JSP 1.2 specification (items changed/added in bold)].

contentType Defines the character encoding for the JSP page and for the response of the JSP page and the MIME type for the response of the JSP page.
Values are either of the form "TYPE" or "TYPE;charset=CHARSET" with an optional white space after the ";". CHARSET, if present, must be the IANA value for a character encoding. TYPE is a MIME type, see the IANA registry for useful values.
The default value for TYPE is "text/html" for JSP Pages in standard syntax, or "text/xml" for JSP Documents in XML syntax. If CHARSET is not specified, but the page encoding for the JSP page is specified, CHARSET defaults to the specified page encoding. Otherwise, if neither CHARSET nor the page encoding for the JSP page is specified, the default value for CHARSET is ISO-8859-1 for JSP Pages in standard syntax, or UTF-8 for JSP Pages in XML syntax.
See Chapter 3 for complete details on character encodings.

JSP.3.1. Page Character Encoding

[This section supplements section JSP.3.1 in the JSP 1.2 specification]

The following table (JSP.3-1) clarifies the relationship between the declared page encoding and content type and the input JSP page character encoding.

Table JSP.3-1 Effects of declared page encoding and content type on JSP source encoding and output content type.
pageEncoding Page Directive Attribute
(<encoding>)
contentType Page Directive Attribute
(<contentType>)
Input JSP Source Encoding Output Content Type
specified specified <encoding> <contentType>
specified not specified <encoding> "<defaultType>;charset=<encoding>"
not specified specified <contentType charset> <contentType>
not specified not specified <defaultInputEncoding> "<defaultType>;charset=<defaultEncoding>"
Where:
  • <defaultType> is "text/html" for JSP Pages in standard syntax, or "text/xml" for JSP Documents in XML syntax.
  • <defaultEncoding> is "ISO-8859-1" for JSP Pages in standard syntax, or "UTF-8" for JSP Documents in XML syntax.
  • <defaultInputEncoding> is "ISO-8859-1" for JSP Pages in standard syntax, or "UTF-8" or "UTF-16" for JSP Documents in XML syntax (depending on the type detected as per the rules in the XML specification). Note that, in the case of include directives, the default input encoding is derived from the initial page, not from any of the included pages.

JSP.3.2. Static Content Type

[The following text replaces the third paragraph of section JSP.3.2 in the JSP 1.2 specification (additions/changes in bold)]

For JSP Pages in standard syntax, the default value for TYPE is "text/html" and the default value for the character encoding is ISO-8859-1. For JSP Documents in XML syntax, the default value for TYPE is "text/xml" and the default value for the character encoding is UTF-8. Table JSP.3-1 clarifies the relationship between the declared page encoding and content type and the output content type used.

JSP.3.3. Dynamic Content Type

[This section replaces section JSP.3.3 in the JSP 1.2 specification]

Some JSP pages are designed so they can deliver content using different content types (and character sets) depending on request time input. These pages may be organized as custom actions or scriptlets that determine the response content type and provide glue into other code actually generating the content of the response.

The initial content type for the response (including the character set) is determined as shown in the "Output Content Type" column in Table JSP.3-1. In all cases, the container must call response.setContentType() with the initial content type before processing the page.

The content type (and character set) can then be changed dynamically by calling setContentType() or setLocale() on the response object. The most recent call takes precedence. Changing the content type can be done up until the point where the response is committed. Data is sent to the response stream on buffer flushes for buffered pages, or on encountering the first content (beware of whitespace) on unbuffered pages. Whitespace is notoriously tricky for JSP Pages in JSP syntax, but much more manageable for JSP Documents in XML syntax.

JSP.B.1 DTD for JSP Documents

[This section replaces the ATTLIST declaration for the jsp:directive.page element found in section JSP.B.1 in the JSP 1.2 specification (additions/changes in bold)]

    <!-- 
      The contentType default is not relevant for XML views of
      JSP pages since it differs depending on the originating
      syntax (text/html;ISO-8859-1 for JSP Pages in standard syntax, or
      text/xml;UTF-8 for JSP Documents in XML syntax.
    -->
    <!ATTLIST jsp:directive.page
      language		CDATA		"java"
      extends		%ClassName;	#IMPLIED
      contentType 	%Content;  	text/xml; UTF-8
      import 		CDATA 		#IMPLIED 
      session 		%Bool;  	true  
      buffer 		CDATA  		8kb  
      autoFlush 	%Bool;  	true  
      isThreadSafe 	%Bool;  	true
      info 		CDATA 		#IMPLIED 
      errorPage 	%URL; 		#IMPLIED 
      isErrorPage 	%Bool;  	false  
    > 
	  

JSP.B.2 XSchema Description of JSP Documents

[This section replaces the directive.page element declaration in section JSP.B.2 in the JSP 1.2 specification (additions/changes in bold)]

    <xsd:element name = "directive.page">
      <xsd:annotation> 
	<xsd:documentation> 
	  directive.page is the "page directive". 
	  The contentType default is not relevant for XML views of
	  JSP pages since it differs depending on the originating
	  syntax (text/html;ISO-8859-1 for JSP Pages in standard syntax, or
	  text/xml;UTF-8 for JSP Documents in XML syntax.
	</xsd:documentation> 
      </xsd:annotation> 
      <xsd:complexType> 
	<xsd:attribute ref = "jsp:id"/> 
	<xsd:attribute name = "language" default = "java" type = "xsd:string"/>
	<xsd:attribute name = "extends" type = "TypeName"/>
	<xsd:attribute name = "contentType" default = "text/xml; UTF-8" type = "ContentType"/> 
	<xsd:attribute name = "pageEncoding" use = "optional" type = "PageEncoding"/> 
	<xsd:attribute name = "import" type = "ImportList"/>
	<xsd:attribute name = "session" default = "true" type = "Bool"/>
	<xsd:attribute name = "buffer" default = "8kb" type = "BufferSize"/>
	<xsd:attribute name = "autoFlush" default = "true" type = "Bool"/>
	<xsd:attribute name = "isThreadSafe" default = "true" type = "Bool"/>
	<xsd:attribute name = "info" type = "xsd:string"/>
	<xsd:attribute name = "errorPage" type = "RelativeURL"/>
	<xsd:attribute name = "isErrorPage" default = "false" type = "Bool"/>
      </xsd:complexType>
    </xsd:element>