Is it possible to disable support for references to static fields and methods in Tomcat 8, which was added as part of Unified Expression Language 3.0.
We have ~ 4K JSP in our application with many expressions ${undefined}(without scope), switching to Tomcat 8 leads to a significant decrease in performance, since evaluating these expressions is the legal value of "null". We no longer use JSP technology for new pages, but outdated ones will not disappear soon.
The problematic code is in the javax.servlet.el.ScopedAttributeELResolver class , which is trying to resolve the expression from ImportHandler, which makes a lot of Class.forName lookup requests, which is largely due to a ClassNotFoundException.
@Override
public Object getValue(ELContext context, Object base, Object property) {
if (context == null) {
throw new NullPointerException();
}
Object result = null;
if (base == null) {
context.setPropertyResolved(base, property);
if (property != null) {
String key = property.toString();
PageContext page = (PageContext) context
.getContext(JspContext.class);
result = page.findAttribute(key);
if (result == null) {
ImportHandler importHandler = context.getImportHandler();
if (importHandler != null) {
Class<?> clazz = importHandler.resolveClass(key);
if (clazz != null) {
result = new ELClass(clazz);
}
if (result == null) {
clazz = importHandler.resolveStatic(key);
if (clazz != null) {
try {
result = clazz.getField(key).get(null);
} catch (IllegalArgumentException | IllegalAccessException |
NoSuchFieldException | SecurityException e) {
}
}
}
}
}
}
}
return result;
}
Update
For problems with Tomcat 8 - errors were detected when using unlimited optional attributes , which is closed since it will not be fixed. I thought they could add some property to disable code that requires high performance, but so far they won't be, due to:
- This will be specific to Tomcat.
- This must be a system property, as it is a specification class.
- It cannot be applied for each application - this will affect all applications running in this instance.
Advise thanks