D
david
I'm in the midst of developing a small webapp, I'm a beginner. And,
I've run into an error I don't understand.
I'm posting a session attribute in an Action...
curSession.setAttribute("testorg", O); where O is a vector containing
orgVO class objects.
Here is my jsp...
---------------------------------------------------------------------------
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="Beans.*, java.util.*" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%
orgVO[] newOrg = new orgVO[1];
newOrg[0] = new orgVO("david", "test");
out.println(newOrg[0].getorgName());
HttpSession catalogSession = request.getSession(true);
Vector test = (Vector) catalogSession.getAttribute("testorg");
Object [] orgtest = test.toArray();
Object d = orgtest[0];
Class x = d.getClass();
String classX = x.getName();
out.println("**" + classX + "**");
//orgVO testd = (orgVO) d;
if (test == null) {out.println("test data not received");} else {
int i = test.size();
out.println("size = " + i);
for (int x1 = 0; x1 < i; x1++){
// orgVO t = (orgVO) test.elementAt(x);
// out.println(t.getorgName());
// out.println(test.elementAt(x).getorgName());
}
out.println("test data received");}
%>
//<logic:iterate id="element" collection="<%=test %>"
type="Beans.orgVO">
//<bean:write name="element" property="orgName" filter="true"/>
//</logic:iterate>
<html:html locale="true">
<head>
<title><bean:message key="index.title" /></title>
<html:base/>
</head>
</html:html>
---------------------------------------------------------------
when I run the jsp with the above as is (with the casting commented
out) it works. I see that there are 83 objects in the vector, and
that they are of class orgVO. Additionally, the initial section
instantiates an orgVO class and I'm able to print out the name.
However, If i uncomment the code I get a class cast exception for
orgVO - i get this same exception with the using the iterate bean and
with the java code.
error:
org.apache.jasper.JasperException: orgVO
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)...
root cause
java.lang.ClassCastException: orgVO
at org.apache.jsp.catalog_jsp._jspService(catalog_jsp.java:116)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)...
Any one have any ideas/suggestions?
thanks,
david
I've run into an error I don't understand.
I'm posting a session attribute in an Action...
curSession.setAttribute("testorg", O); where O is a vector containing
orgVO class objects.
Here is my jsp...
---------------------------------------------------------------------------
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="Beans.*, java.util.*" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%
orgVO[] newOrg = new orgVO[1];
newOrg[0] = new orgVO("david", "test");
out.println(newOrg[0].getorgName());
HttpSession catalogSession = request.getSession(true);
Vector test = (Vector) catalogSession.getAttribute("testorg");
Object [] orgtest = test.toArray();
Object d = orgtest[0];
Class x = d.getClass();
String classX = x.getName();
out.println("**" + classX + "**");
//orgVO testd = (orgVO) d;
if (test == null) {out.println("test data not received");} else {
int i = test.size();
out.println("size = " + i);
for (int x1 = 0; x1 < i; x1++){
// orgVO t = (orgVO) test.elementAt(x);
// out.println(t.getorgName());
// out.println(test.elementAt(x).getorgName());
}
out.println("test data received");}
%>
//<logic:iterate id="element" collection="<%=test %>"
type="Beans.orgVO">
//<bean:write name="element" property="orgName" filter="true"/>
//</logic:iterate>
<html:html locale="true">
<head>
<title><bean:message key="index.title" /></title>
<html:base/>
</head>
</html:html>
---------------------------------------------------------------
when I run the jsp with the above as is (with the casting commented
out) it works. I see that there are 83 objects in the vector, and
that they are of class orgVO. Additionally, the initial section
instantiates an orgVO class and I'm able to print out the name.
However, If i uncomment the code I get a class cast exception for
orgVO - i get this same exception with the using the iterate bean and
with the java code.
error:
org.apache.jasper.JasperException: orgVO
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)...
root cause
java.lang.ClassCastException: orgVO
at org.apache.jsp.catalog_jsp._jspService(catalog_jsp.java:116)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)...
Any one have any ideas/suggestions?
thanks,
david