Skip to Content
0
Former Member
May 14, 2005 at 05:06 AM

ClassCastException while accessing Java Object in JSP - Please help

14 Views

Hi All,

We have a simple POJO (Plain old Java Object) that implements Serializable. The portal component invokes a Stateless Session Bean which returns a POJO (this is done using the "SharingReference" property in the portal-app.xml). The portal component then stores the POJO in the HttpSession. We are trying to access the POJO in the JSP using something like

<% Person person = (Person) session.getAttribute("person"); %>

This is where it fails. Since it can't reference the "Person" class (the JSP contains the import of the package). The Person class is in a Java Project that's JAR(red) and available to the EJB Project. When we put the same JAR in the /PORTAL-INF/lib folder and invoked the JSP, we get a ClassCastException (since the object in the session is different than the one being referenced in the JSP). So the question is how can we pass the POJO across the EJB, Portal and JSP containers?

Any reply to this message is highly appreciated.

Thank you for your time.

Best Regards,

Vasu