https://bz.apache.org/bugzilla/show_bug.cgi?id=69635
Bug ID: 69635
Summary: JSP fails to import nested enum or class
Product: Tomcat 10
Version: 10.1.39
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: Jasper
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ------
This should work:
<code>
package business.domain;
public class Category {
public enum Type { HIGH, MEDIUM, LOW }
// Workaround
public static Type[] getTypeValues() {
return Type.values();
}
}
</code>
In the JSP:
*Attempt 1: Import the class access enum through class (statically).*
<code>
<%@page import="business.domain.Category" %>
<%-- This fails: Error: No public static field named [Type] was found on
exported class [business.domain.Category]
Category types: ${Category.Type.values()}<br>--%>
<%-- Workaround: Static method on Category --%>
Category types: ${Category.getTypeValues()}
</code>
*Attempt 2: Import enum Type directly.*
<code>
<%@page import="business.domain.Category.Type" %>
<%-- Type is null; no output shown --%>
Category types: ${Type.values()}
</code>
*Attempt 3: Import enum Type using nested class name like Class$NestedClass.*
<code>
<%@page import="business.domain.Category$Type" %>
<%-- Unable to compile class for JSP: An error occurred at line: .. import
business.domain.Category$Type cannot be resolved Stacktrace:... --%>
</code>
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]