If a single page directive is split into multiple instances (according to JSP.2.10.1 "The page Directive"), the "pageEncoding" attribute is ignored under the following conditions: 1) The page directive that contains the "pageEncoding" attribute is NOT defined in the same instance as the "contentType" attribute. 2) The page directive that contains the "pageEncoding" attribute appeares AFTER the directive that contains the contentType" attribute. If both conditions are true, pageEncoding is ignored and instead, the character encoding specified by the "contentType" attribute seems to be used! example 1: <%@page contentType="text/html; charset=UTF-8"%> <%@page pageEncoding="ISO-8859-1"%> used charset: I don't know, but it is NOT ISO-8859-1, because special LATIN-1 characters are "unreadable" in the generated java servlet code. example 2: <%@page pageEncoding="ISO-8859-1"%> <%@page contentType="text/html; charset=UTF-8"%> used charset: ISO-8859-1 (which is correct!) At least it is a bug that the page directives are position dependent! (see JSP.2.10.1 "The page Directive"). This bug has already been fixed in Tomcat 5 (see bug #29342 and bug #27517)
There is some ambiguity in the JSP 1.2 spec regarding page encoding and content type. This was clarified in http://www.jcp.org/aboutJava/communityprocess/maintenance/jsr053/errata_1_2_a_2 0020321.html This bug actually has the same root cause as 25899, hence I am marking this one as a duplicate. *** This bug has been marked as a duplicate of 25899 ***