This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one 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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp:useBean  ClassCastException" Watch "jsp:useBean  ClassCastException" New topic
Author

jsp:useBean ClassCastException

Reginald Law
Greenhorn

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.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

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
Greenhorn

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: http://aspose.com/file-tools
 
subject: jsp:useBean ClassCastException