--- java/org/apache/el/parser/AstValue.java (revision 656725) +++ java/org/apache/el/parser/AstValue.java (working copy) @@ -37,7 +37,13 @@ * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author$ */ public final class AstValue extends SimpleNode { + private static final boolean STRICT_SERVLET_COMPLIANCE; + static { + STRICT_SERVLET_COMPLIANCE = "true".equals(System.getProperty( + "org.apache.catalina.STRICT_JSP_COMPLIANCE", "false")); + } + protected static class Target { protected Object base; @@ -129,12 +135,26 @@ Target t = getTarget(ctx); ctx.setPropertyResolved(false); ELResolver resolver = ctx.getELResolver(); - resolver.setValue(ctx, t.base, t.property, - // coerce to the expected type - ELSupport.coerceToType(value, - resolver.getType(ctx, t.base, t.property))); + + // coerce to the expected type + Class targetClass = resolver.getType(ctx, t.base, t.property); + if (STRICT_SERVLET_COMPLIANCE == true + || !isAssignable(value, targetClass)) { + value = ELSupport.coerceToType(value, targetClass); + } + + resolver.setValue(ctx, t.base, t.property, value); } + private boolean isAssignable(Object value, Class targetClass) { + if (value != null && targetClass.isPrimitive()) { + return false; + } else if (value != null && !targetClass.isInstance(value)) { + return false; + } + return true; + } + public MethodInfo getMethodInfo(EvaluationContext ctx, Class[] paramTypes) throws ELException { Target t = getTarget(ctx);