Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

useBean and type vs class

 
peter john greaves
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 528
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
peter john greaves
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic