Meaningless Drivel is fun!
The moose likes JSP and the fly likes jsp:useBean  ClassCastException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp:useBean  ClassCastException" Watch "jsp:useBean  ClassCastException" New topic

jsp:useBean ClassCastException

Reginald Law

Joined: Jan 21, 2004
Posts: 19
I have a jsp where I use jsp:useBean. I only get the exception in the JSP after I try to update the bean in the session data (in a struts action class). Should beans only be read only, set up once never to be changed ?

I am getting this error on Jrun4.

If I initialize the bean with some initial values things work fine. It is only after I do an update to the session data that I get the error.

Now I see why sun came up with the ejb session beans. You know they work and they are reliable.

Are their undocumented scope restrictions on the jsp:useBean tag ? What application servers does this work best with.

SCJP 1.4
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
You're going to need to give some more info on this. Where exactly are you getting the casting exception, etc. Maybe post the code in question.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63868

There are no weird restrictions. You are probably just casting the bean incorrectly somehwere. As pointed out, more info would be needed for further diagnosis.

[Asking smart questions] [About Bear] [Books by Bear]
Reginald Law

Joined: Jan 21, 2004
Posts: 19
I found the problem. I was using the wrong class indeed. The session.setAttribute does work.
I agree. Here's the link:
subject: jsp:useBean ClassCastException
jQuery in Action, 3rd edition