This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 60800

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] [Bear's FrontMan] [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.
Consider Paul's rocket mass heater.
subject: jsp:useBean ClassCastException
Similar Threads
Writer or Streamer already obtained (??)
need help running jsps with tomcat 4.1
URGENT Help Needed ...!!
How to update Session variable with Form Data ?
Question about Java Beans