To understand how the changes in the JSP specification can
result in fatal translation errors, please review the following scenarios.
Scenario 1:
If a.jsp contains the following code:
<%@ page contentType="text/html;charset=GBK"%>
and
<%@include file="b.jsp" %>
And if b.jsp doesn't contain a contentType charset page
attribute, this scenario will run successfully on WebSphere 5.x but will
fail on WebSphere 6.x.
Scenario 2:
If a.jsp contains the following code:
<%@ page contentType="text/html;charset=GBK"%>
and
<%@include file="b.jsp" %>
And if b.jsp also contains:
<%@ page contentType="text/html;charset=GBK"%>
Then this scenario will fail on WebSphere 5.x and will run successfully
on WebSphere 6.x.
Scenario 3:
If a.jsp contains the following code:
<%@ page contentType="text/html;charset=GBK"%>
and
<%@include file="b.jsp" %>
And if b.jsp contains:
<%@ page
contentType="text/html;charset=ISO-8859-1"%>
Then this scenario will fail on both WebSphere 5.x and WebSphere
6.x.
Explanation of above Scenarios
This difference in behavior results from the fact that WebSphere 5.x
follows JSP Specification 1.2 while WebSphere 6.x follows JSP
Specification 2.0.
In the Preface of the JSP version 2.0, the section titled "Backwards
Compatibility with JSP 1.2" states:
"...in JSP 1.2, page encodings are determined on a per translation unit
basis whereas in JSP 2.0, page encodings are determined on a per-file
basis. Therefore, if a.jsp statically includes b.jsp,
and a page encoding is specified in a.jsp but not in
b.jsp, in JSP 1.2 a.jsp’s encoding is used for
b.jsp, but in JSP 2.0, the default encoding is used for
b.jsp."
Elsewhere, the JSP specification 2.0 states (Section JSP.1.10.1):
"The pageEncoding attribute can occur at most once per file (or a
translation error will result), and applies only to the file in which it
appears. Other such multiple attribute/value (re)definitions result in a
fatal translation error if the values do not match."
Accordingly, two different charset values in files a.jsp and
b.jsp are also not valid. This is why scenario 3 fails on
WebSphere 5.x (JSP 1.2) and WebSphere 6.x (JSP 2.0).
The JavaServer Pages Specification can be found here: http://java.sun.com/products/jsp/
|