aspose file tools*
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 Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "useBean and type vs class" Watch "useBean and type vs class" New topic
Author

useBean and type vs class

peter john greaves
Greenhorn

Joined: Jan 12, 2006
Posts: 4
hi

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

{myservlet}?username=bertie

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)

regs

peter
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.

Regards,
Mars.


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJD, SCEA/OCMJEA

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

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!

regs

peter
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: useBean and type vs class