jQuery in Action, 3rd edition
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes useBean and type vs class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "useBean and type vs class" Watch "useBean and type vs class" New topic

useBean and type vs class

peter john greaves

Joined: Jan 12, 2006
Posts: 4

i found this behaviour a bit odd - given a bean in the request scope set like this in a servlet:

and a view like this:

and a call like


i am not really sure why i should expect the setProperty to be called and the output "pooh". there surely is an object of reference type Person in the request. and as Person is abstract, it can't be instantiated : without a class attribute, there's no way for the Container to do it! so it looks to me like the setProp is being called although the bean already exists.

i can see the (WAS 5.1) generated code looking like this:

anyone help here? (i dont have tomcat installed on this client or i'd test it outside my local WAS environment)


Marcelo Ortega
Ranch Hand

Joined: May 31, 2005
Posts: 528

Hi Peter.

According to the specs, the body of the jsp:useBean should not be invoked because the foo.Person object has already been created (and if it isn't when it gets to jsp:useBean, an exception will be thrown).
I would try the code under Tomcat, because if you can guarantee that eveything is as it should be, then the jsp:setProperty standard action should not be reached.



Live life to an interface, not an implementation!
peter john greaves

Joined: Jan 12, 2006
Posts: 4
well, well. under tomcat (5.5) i get the expected output "bertie" : IOW the setter isnt called. think i'll stick with tc for my tests. thanks for the reply!


I agree. Here's the link: http://aspose.com/file-tools
subject: useBean and type vs class
It's not a secret anymore!