uCosminexus Application Server, Web Container Functionality Guide
- To include a file in the include directive of the JSP file, specify encoding in the JSP file that forms the include source.
- To include a static file such as HTML in JSP, use the include directive instead of the include action. Use the include action to include dynamic pages such as JSPs and servlets.
- When you create a tag library, make sure that you add the package name with the package statement at the beginning of the class file that describes the tag library. If the package name is not added, that tag library does not function normally.
- Specify either NESTED, AT_BEGIN, or AT_END in the <scope> tag element in the <variable> tag in the tag library descriptor (TLD file). If other values are specified, the default value NESTED is assumed and executed.
- When you implement the tag handler of the tag library, specify settings such that the doStartTag method, the doAfterBody method, and the doEndTag method return the return value defined in the specifications. If a value other than the return value defined in the specifications is returned, the default return value is assumed. The default return value is the return value returned when the methods of the javax.servlet.jsp.tagext.TagSupport or javax.servlet.jsp.tagext.BodyTagSupport class are not overridden. For example, in the class that implements the BodyTag interface (or class that inherits the BodyTagSupport class), if the doStartTag method returns EVAL_PAGE as the return value, it is assumed that the default return value EVAL_BODY_BUFFERED is returned.
- When the Web application version is 2.3 and when a custom tag with attributes specified in the tag handler of the tag library is implemented, if you specify the same attribute in the JSP custom tag multiple times, the setter method of the relevant tag handler is invoked for the specified number of times. If a setter method that overwrites a normally specified value is implemented, the attribute value coded later is enabled.
- Do not specify a null character string as a tag element in the tag library descriptor (TLD) file. Examples of specifying null character strings are cases where no string is coded between the beginning tag and ending tag (for example, <param-name></param-name>) or cases where a tag with a null element (for example, <param-name />) is coded. If a null character string is specified for a tag element, operation is not guaranteed.
- Use an absolute path to specify the xsi:schemaLocation attribute in the Tag Library Descriptor (TLD) file.
- When you use the extension element of tags or a tag library in the TLD file, and specify the xsi:schemaLocation attribute with a relative path, operation is not guaranteed.
When using the <%= %> tag in JSP, make sure that you do not include a semicolon (;) in the tag. If the semicolon is entered, an error occurs during JSP compilation.
When you access the JSP file path directly by specifying the URL and when you access the path using a URL with the mapping defined, separate instances are generated in each case. Therefore, note that the jspInit method is executed in each instance. If the specification in the in the <load-on-startup> tag is to load the instance during startup, the instance loaded during startup is same as the one that is accessed using the URL with the mapping defined.
Make sure that you specify the plugin action or the code attribute of the <jsp:plugin> tag in the JSP document on the JSP page. If omitted, a compilation error occurs.
In the JSP document, describe the information about the version used as the attribute of the <jsp:root> tag. However, the scope of functionality available in JSP is in accordance with the version information of web.xml of the Web application containing the relevant JSP.
For example, even if the JSP document describes <jsp:root version="1.2">, you can use JSP EL added in the JSP 2.0 specifications.
(7) Mapping of URI and TLD files specified in the uri attribute of the taglib directive
The URI specified in the uri attribute of the taglib directive is mapped using one of the following methods as per the JSP specifications. You cannot map the same URI to a different TLD file. If the URI is duplicated, the following numbering is considered as the priority order and the mapping with a higher priority order is enabled:
- Implicit mapping of JSTL and JSF URI (Web application of Servlet 2.5 or later specifications)
- Mapping of URI specified in the <taglib-uri> element of the <taglib> element in web.xml with the TLD file specified in the <taglib-location> element
- Mapping of the URI specified in the <uri> element of the TLD file in the Web application with the same TLD file
- Mapping of the URI specified in the <uri> element of the TLD file stored under the /META-INF directory of the library JAR (in the case of the cjjspc command, the JAR file specified in the -classpath option) with the same TLD file
The examples of description of directory structures and files used when the URI and TLD files are mapped as specified from step 2 to 4 are as follows:
(a) Mapping of the URI specified in the <taglib-uri> element of the <taglib> element in web.xml and the TLD file specified in the <taglib-location> element (in 2.)
An example of description of the directory structure and files in the case of point 2 is as follows:
In the case of point 2, the TLD file is stored in the Web application. The example of the directory structure in point 2 is as follows:
Figure 6-3 Directory structure (in the case of point 2.)
The following figure shows the mapping of the URI specified in the uri attribute of the taglib directive and the TLD file for this directory structure.
Figure 6-4 Mapping of the URI and TLD file (in the case of point 2.)
The correspondence of data in the figure is explained below:
- The prefix specified in the taglib directive is specified in the tag prefix.
- The value specified in the <name> element of the TLD file is associated with the JSP file prefix.
- The uri specified in the taglib directive of the JSP file is specified in the <taglib-uri> element of web.xml.
- The name of the TLD file to be mapped is specified in the <taglib-location> element of web.xml.
(b) When mapping the URI specified in the <uri> element of the TLD file and the same TLD file
An example of description of the directory structure and files in the case of points 3 or 4 is described here.
In the case of point 3, the TLD file is stored in the Web application. The example of the directory structure in point 3 is as follows:
Figure 6-5 Directory structure (in the case of point 3)
In the case of point 4, the TLD file is stored under the /META-INF directory of library JAR. The example of the directory structure in point 4 is as follows:
Figure 6-6 Directory structure (in the case of point 4)
The following figure shows the mapping of the URI specified in the uri attribute of the taglib directive and the TLD file in the directory structure for the points 3 or 4:
Figure 6-7 Mapping of the URI specified in the <uri> element of the TLD file and the same TLD file (in the case of points 3 or 4)
The correspondence of data in the figure is explained below:
- The prefix specified in the taglib directive is specified in the tag prefix.
- The value specified in the <name> element of the TLD file is associated with the JSP file prefix.
- The uri specified in the taglib directive of the JSP file is specified in the <url> element of TLD file.
If a duplicate URI is detected, the following messages are output for the Web applications and the relevant mapping is ignored:
Table 6-22 Messages output and the output conditions in the case of URI duplication
Message ID |
Output conditions |
KDJE39314-W |
- In the case of the J2EE server mode, servlet engine mode, or cjjspc command
- This message is output when the contents of the <uri> element described in the TLD files are duplicated with the contents of the <taglib-uri> element in web.xml or the contents of the <uri> element described in another TLD file.
- In the case of the cjjsp2java command
- This message is output when the contents of the <uri> element described in the TLD file are duplicated with the uri contents specified in the command argument -taglib or the contents of the <uri> element described in another TLD file.
|
KDJE39315-W |
This message is output when the contents of the <uri> element described in the TLD file are duplicated with the contents of the <uri> element described in another TLD file. |
KDJE39316-W |
This message is output when another <taglib> element is specified containing the <taglib-uri> element that duplicates with the contents of <taglib> element specified in web.xml. |
KDJE39325-W |
This message is output when the contents of the <taglib-uri> element of web.xml or the contents of the <uri> element described in another TLD file is duplicated with the URI of the tag library (JSTL, and JSF) in the Java EE specifications. |
KDJE39326-W |
This is message is output when the contents of the <uri> element of the TLD file stored in the library JAR (in the case of the cjjspc command, JAR file specified in the -classpath option) are duplicated with the contents of the <taglib-uri> element of web.xml or the contents of the <uri> element described in another TLD file. |
(8) Notes for including a dynamic page in JSP
To include dynamic pages such as JSPs and servlets in JSP, use the include action instead of the include method of javax.servlet.RequestDispatcher.
(9) Coding the internal subset to the DOCTYPE declaration in the TLD file
Do not code the internal subset for the DOCTYPE declaration in the TLD file (tag library descriptor).
You can only specify absolute URI as the URI specified in the xsi:schemaLocation attribute with the tag element extension or the element extension of the tag library. Do not reference definitions other than DTD/ XML schema defined in the Java EE specifications with purposes other than tag element extension or the element extension of the tag library.
(10) Specifying the external subset URI in the JSP document and XML tag file
When you specify the DOCTYPE declaration, you can only specify the absolute URI as the external subset URI. Also, when you reference the external entity defined in the XML1.0 specifications, you can only specify the absolute URI as the URI specified in the external entity declaration. You cannot reference the external subset and external entity with the relative URI specified.
(11) Values of the javax.servlet.jsp.jspException attribute of the javax.servlet.ServletRequest object
When an exception is thrown in the JSP file and if the error page is specified in the errorPage attribute of the page directive, the exception is described in the JSP specifications if the error page is set in the javax.servlet.jsp.jspException attribute of the javax.servlet.ServletRequest object, but the exception is also set when the error page is specified in the errorPage attribute of the page directive.
In 07-00 or later versions, the version of the TLD file (JSP version to which the TLD file corresponds) is checked during JSP translation. Therefore, if the TLD file version is a JSP of a level higher than the version of JSP and TLD file corresponding to the Web application version, an error occurs in JSP translation. Also, in JSP 1.2 and in JSP 2.0 or later specifications, the schema language must be defined in the TLD file.
The TLD file version is determined from the schema language described in the TLD file. However, if the schema language is not defined, the TLD file version is determined from the Web application version.
The following table lists the versions of TLD file when the schema language is not defined in the TLD file:
Table 6-23 TLD file version when the schema language is not defined
Version of the Web application |
TLD file version |
2.2 |
1.1 |
2.3 |
1.2 |
2.4 |
2.0 |
2.5 |
2.1 |
(13) Character encoding supported in JSP
This point describes the character encoding that can be used in the JSP file and tag file.
(a) In the case of the JSP page
The character encoding that can be used on the JSP page and the specification method of character encoding is described below:
- Character encoding that can be used on the JSP page
The character encoding supported by JavaVM can be used. For details on the character encoding supported by JavaVM, see the JDK documentation.
However, the character encoding where the alphanumeric characters, such as UTF-16, are expressed in multiple bytes, must fulfill the following two conditions:
- The Web application is compliant with Servlet 2.4/ JSP 2.0 or later specifications.
- BOM is added at the beginning of the JSP file.
- Specification method of character encoding
You can specify the character encoding you want to use in the JSP page by choosing one or more methods from the methods described below:
- Add BOM at the beginning of the JSP page (in the case of Web applications compliant with Servlet 2.5/JSP 2.1 or later specifications).
- Specify the character encoding in the <page-encoding> element in the <jsp-property-group> element of web.xml (in the case of Web applications compliant with Servlet 2.4/JSP 2.0 or later specifications).
- Specify the character encoding in the pageEncoding attribute of the page directive (in the case of Web applications compliant with Servlet 2.3/JSP 1.2 or later specifications).
- Specify the character encoding in the contentType attribute of the page directive.
The strings that can be specified are the character encoding described in the canonical name for java.nio API and canonical name for java.lang API and their alias names.
Make sure that the character encoding you want to specify matches with the character encoding used on the JSP page.
(b) In the case of the JSP document (in the case of the Web applications compliant with Servlet 2.4 or later specifications)
The character encoding that can be used in the JSP documents in the Web application compliant with the Servlet 2.4 or later specifications and the specification method of the character encoding to be used is described below:
- Character encoding that can be used in the JSP document
You can use the character encoding# supported by the Cosminexus XML Processor.
However, for JSP documents without the extension jspx, if the <is-xml> element is not specified in the <jsp-property-group> element of web.xml, ISO-10646-UCS-4 cannot be used in the character encoding of the JSP document.
However, the character encoding where the alphanumeric characters, such as UTF-16, are expressed in multiple bytes, must fulfill the following two conditions:
- BOM is added at the beginning of the JSP document
- If ISO-10646-UCS-2 is used, ISO-10646-UCS-2 of big-endian is used
- Specification method of character encoding
Specify the character encoding used in the JSP document in the encoding attribute of the XML declaration. The specifiable strings are the character encoding# supported by the Cosminexus XML Processor.
However, for JSP documents without the extension jspx, if the <is-xml> element is not specified in the <jsp-property-group> element of web.xml, specify the character encoding you want to use by choosing one or more methods from the methods described below:
- Specify the character encoding in the encoding attribute of the XML declaration.
- Specify the character encoding in the <page-encoding> element in the <jsp-property-group> element of web.xml.
- Specify the character encoding in the pageEncoding attribute of the page directive.
The strings that can be specified are the character encoding described in the canonical name for java.nio API and canonical name for java.lang API and their alias names.
Make sure that the character encoding you want to specify matches with the character encoding used in the JSP document.
- Note
- For the character encoding supported by the Cosminexus XML Processor, see 1.3.2 Character codes that can be processed in the uCosminexus Application Server XML Processor User Guide.
(c) In the case of the JSP document (in the case of the Web applications compliant with Servlet 2.3 specifications)
The character encoding that can be used in the JSP documents in the Web application compliant with the Servlet 2.3 specifications and the specification method of the character encoding to be used is as follows:
- Character encoding that can be used in the JSP document
You can use the character encoding supported by the Cosminexus XML Processor. For on character encoding supported by the Cosminexus XML Processor, see 1.3.2 Character codes that can be processed in the uCosminexus Application Server XML Processor User Guide.
However, the character encoding where the alphanumeric characters, such as UTF-16, are expressed in multiple bytes cannot be used.
- Specification method of character encoding
You can specify the character encoding you want to use in the JSP document by choosing both or one of the methods described below:
- Specify the character encoding in the encoding attribute of the XML declaration.
- Specify the character encoding in the pageEncoding attribute of the page directive.
The strings that can be specified are the character encoding described in the canonical name for java.nio API and canonical name for java.lang API and their alias names.
Make sure that the character encoding you want to specify matches with the character encoding used in the JSP document.
(d) In the case of the tag file with standard syntax
The character encoding that can be used in the tag file with the standard syntax and the specification method of the character encoding to be used is described below:
- Character encoding that can be used in the tag file
You can use the character encoding supported by JavaVM. For details on the character encoding supported by JavaVM, see the JDK documentation.
However, for the character encoding where the alphanumeric characters, such as UTF-16, are expressed in multiple bytes, BOM must be added at the beginning of the tag file.
- Specification method of character encoding
You can specify the character encoding you want to use in the tag file by choosing both or one of the methods described below:
- Add BOM at the beginning of the tag file (in the case of the Web applications compliant with Servlet 2.5/JSP 2.1 or later specifications).
- Specify the character encoding in the pageEncoding attribute of the tag directive (in the case of the Web applications compliant with Servlet 2.4/JSP 2.0 or later specifications).
The strings that can be specified are the character encoding described in the canonical name for java.nio API and canonical name for java.lang API and their alias names.
Make sure that the character encoding you want to specify matches with the character encoding used in the tag file.
(e) In the case of the tag file with XML syntax
The character encoding that can be used in the tag file with the XML syntax and the specification method of the character encoding to be used is described below:
- Character encoding that can be used in the tag file
You can use the character encoding# supported by the Cosminexus XML Processor.
- Specification method of character encoding
Specify the character encoding to be used in the tag file according to the XML1.0 specifications. The strings that can be specified are the character encoding# supported by the Cosminexus XML Processor.
Make sure that the character encoding you want to specify matches with the character encoding used in the tag file.
- Note:
- For the character encoding supported by the Cosminexus XML Processor, see 1.3.2 Character codes that can be processed in the uCosminexus Application Server XML Processor User Guide.
(f) Default character encoding
If the character encoding is not explicitly specified in the JSP file or tag file, the JSP is processed using the default character encoding.
Note that even in this case, make sure that the default character encoding matches with the character encoding used in the tag file. The following table lists the default character encoding for the Servlet and JSP specifications:
Table 6-24 Default character encoding
Specifications |
JSP page |
JSP document |
Tag file with standard syntax |
Tag file with XML syntax |
Servlet 2.2/ JSP1.1 |
ISO-8859-1 |
ISO-8859-1 |
-- |
-- |
Servlet 2.3/ JSP 1.2 |
ISO-8859-1 |
ISO-8859-1 |
-- |
-- |
Servlet 2.4 or later/ JSP 2.0, JSP 2.1 |
ISO-8859-1 |
UTF-8 |
ISO-8859-1 |
UTF-8 |
- Legend:
- --: Not applicable
You can also set the default character encoding by using the setup functionality for default character encoding. For details, see 2.6 Functionality for setting up the default character encoding.
(14) Notes on using the setProperty action
Do not specify an invalid value in the setProperty action in the JSP page or in the name attribute of the jsp:setProperty tag in the JSP document. Operation is not guaranteed if you specify an invalid value in the name attribute of the jsp:setProperty tag.
(15) Specifying a null character string in an attribute of a JSP tag
Do not specify a null character string in an attribute of a directive or action tag in a JSP page or in a tag that begins with "jsp:" in a JSP document.
(16) Precautions related to coding the scriptlet before and after the template text of JSP
When you want to code a scriptlet that includes a control character such as an if statement before and after the template text of JSP, you must enclose the scriptlet explicitly in "{}" (curly brackets).
As a result of the JSP compilation, a one-lined JSP template text does not necessarily become a one lined statement in the Java file. It is sometimes output as a multi-lined statement. Therefore, if you do not code a scriptlet that includes a control character such as an if statement before and after the template text of JSP, by enclosing it explicitly in the "{}" (curly brackets), unintended operations might occur.
(17) Precautions related to using the scriptlet
When you code the Java code in a JSP by using a scriptlet and you want to code the return statement or throw statement in the scriptlet, code within a block such as an if statement.
(18) Translation error when the EL is disabled
If the JSP includes a character string such as ${aaa, which is incorrect as an EL, an invalid EL translation error occurs even when you set the EL to a disabled status.
The following table lists the EL starting characters for which the translation error occurs for each version of the JSP specifications.
Table 6-25 TableEL starting character for which the translation error occurs
Version of the JSP specifications |
EL starting character |
JSP2.1 |
'$', '#' |
JSP2.0 |
'$' |
JSP1.2 |
None |
(19) Coding schemaLocation in the TLD file
For schemaLocation coded in the TLD file, you must specify either of the values given in the following table, depending on the version of TLD.
Version of TLD |
Value to be specified in schemaLocation |
2.0 |
"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" |
2.1 |
"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd" |
All Rights Reserved. Copyright (C) 2013, Hitachi, Ltd.