uCosminexus Application Server, Web Container Functionality Guide
Notes for specifying the scope
If the script variable name and the script variable scope are repeated in multiple custom tags, the JSP compilation results differ depending on the versions of the Application Server. Specify the script variable scope using one of the followings:
- Subclass of javax.servlet.jsp.tagext.TagExtraInfo class
- Scope element in the variable element of the TLD file
The followings are the differences in operations in each Application Server version when script variables with the same names are specified in the JSP custom tag:
- With versions prior to 07-00
Perform variable declaration of the script variable in the Java code generated from JSP corresponding to the custom tag from the second time onwards.
- With version 07-00 and later versions
Do not perform variable declaration of the script variable in the Java code generated from JSP corresponding to the custom tag from the second time onwards.
The following is an example wherein the scope is AT_BEGIN and custom tag <my:foo> defines the script variable of the variable name (var) specified in the attribute id:
- Example of definition
<my:foo id="var" type="String">
<%=var%>
</my:foo>
<my:foo id="var" type="String">
<%=var%>
</my:foo>
|
- With versions prior to 07-00
Perform variable declaration with the script variable var in the Java code generated from JSP corresponding to the second custom tag. In this case, the range of scope 'AT_BEGIN' in each custom tag is as follows:
Therefore, compilation error occurs during the compilation of the Java source generated from JSP.
- With version 07-00 and later versions
Do not perform variable declaration with the script variable var in the Java code generated from JSP corresponding to the second custom tag. In this case, the range of scope 'AT_BEGIN' in each custom tag is as follows:
Therefore, even if the script variables of the same name are defined in the same scope, the compilation of the Java source generated from JSP is executed normally.
Notes for coding the scriptlet
When the Java source is generated from JSP, the Java code described in the scriptlet is not analyzed. Therefore, if you define the process for which the script variable scope is changed before and after the custom tag or in the body scriptlet, the JSP compiled results might return an error depending on the version of the Application Server version.
- Example of compilation error when the scope is 'AT_BEGIN'
In this example, script variable of variable name (var) specified in the attribute id is defined in the custom tag <my:foo> and scope 'AT_BEGIN'.
<% if(flag) { %>
<my:foo id="var" type="String">
<%=var%>
</my:foo>
<% } else { %>
<my:foo id="var" type="String">
<%=var%>
</my:foo>
<% } %>
|
The operations for each Application Server version in this example are as follows:
- With versions prior to 07-00
Perform variable declaration with script variable var in the Java code generated from JSP corresponding to the second custom tag. Therefore, error does not occur even when referencing the second script variable var. JSP compilation is executed normally.
- With version 07-00 and later versions
In the second custom tag, the analysis is that the script variable var is already declared. In this case, variable declaration will not be performed with variable var in the Java code generated from JSP corresponding to the custom tag. Therefore, an error occurs in the reference of the second script variable var.
(2) Differences in JSP compilation operations depending on the usage of the JSP translation backward compatibility function
The differences in the compilation operations when the JSP translation backward compatibility function is used and when the function is not used with version 07-00 and later versions are as follows:
- When the script variable name and the script variable scope is repeated in multiple custom tags:
- Use the JSP translation backward compatibility function
Perform variable declaration of script variables in Java code generated from JSP corresponding to the custom tag from the second time onwards.
- Do not use the JSP translation backward compatibility function
Do not perform variable declaration of script variables in Java code generated from JSP corresponding to the custom tag from the second time onwards.
(3) Defining the JSP translation backward compatibility function
To define the JSP translation backward compatibility function, specify the following parameter in the <configuration> tag of the logical J2EE server (j2ee-server) in the Easy Setup definition file:
- webserver.jsp.translation.backcompat.customAction.declareVariable
- Specifies whether or not to output the variable declaration of the script variables corresponding to the second custom tag in the Java code generated from the JSP file.
For details on the Easy Setup definition file and the parameters to be specified, see the uCosminexus Application Server Definition Reference Guide.
All Rights Reserved. Copyright (C) 2013, Hitachi, Ltd.