DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15927>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15927 ClassCastException when using the StrutsTag with scriptlets Summary: ClassCastException when using the StrutsTag with scriptlets Product: Struts Version: 1.1 Beta 3 Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: Custom Tags AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] Hi, Jasper generates a ClassCastException if you use scriptlets in the StrutsTag. For example, the following jsp-code gives this error: <logic:iterate id="L0" name="items" type="org.apache.struts.tiles.beans.MenuItem"> <bean:struts id="action" mapping="<%=L0.getLink()%>"/> </logic> When Jasper tries to compile this jsp, a ClassCastException is thrown. This is caused by the implementation of the getVariableInfo(TagData data) method in the StrutsTei class. The following code (taken from the getVariableInfo method) is the cause of this exception: data.getAttributeString("mapping") != null Because when Jasper compiles the jsp, it will put a dummy object in the TagData for the "mapping" attribute because there is no value for that scriptlet at compile time. This dummy object is the TagData.REQUEST_TIME_VALUE object (which is not a String). During compilation, Jasper calls the getVariableInfo method of the StrutsTei class and in this way, a ClassCastException if thrown because an attempt is made to cast TagData.REQUEST_TIME_VALUE to a String. regards, Maarten Coene Here is a simple patch to fix this: cvs diff -u StrutsTei.java Index: StrutsTei.java =================================================================== RCS file: /home/cvspublic/jakarta- struts/src/share/org/apache/struts/taglib/bean/StrutsTei.java,v retrieving revision 1.3 diff -u -r1.3 StrutsTei.java --- StrutsTei.java 12 Feb 2001 01:26:57 -0000 1.3 +++ StrutsTei.java 9 Jan 2003 17:23:22 -0000 @@ -85,11 +85,11 @@ public VariableInfo[] getVariableInfo(TagData data) { String type = null; - if (data.getAttributeString("formBean") != null) + if (data.getAttribute("formBean") != null) type = "org.apache.struts.action.ActionFormBean"; - else if (data.getAttributeString("forward") != null) + else if (data.getAttribute("forward") != null) type = "org.apache.struts.action.ActionForward"; - else if (data.getAttributeString("mapping") != null) + else if (data.getAttribute("mapping") != null) type = "org.apache.struts.action.ActionMapping"; else type = "java.lang.Object"; -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>