• Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt about internal working of jsp:usebean with type and class specified

Matthias De Scheerder
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

With SCWCD exam only 5 days away, I'm doing my final round-up. I have a doubt about the internal working of jsp:usebean when type and class is used.

Now, according to HFSJ, when i put this on my JSP:

the generated code in _jspService is this (package names excluded):

Now, given that:
- Person is an abstract class with attribute "name"
- Employee is a non-abstract subclass of Person with attribute "empID"

Now I call my JSP with following query string:

Tomcat uses introspection to set the properties, and thus both name AND empID are set, even though the type in the _jspService method is the abstract Person that has no empID attribute. In other words: without introspection, this would never work.

My question is: can I rely on this behaviour? Will this always work? Or can/will there be containers that use the regular attribute setter and thus not be able to set the empID property?

Thanks in advance,
[ November 12, 2008: Message edited by: Matthias De Scheerder ]
Christophe Verré
Posts: 14691
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All containers are supposed to use introspection with setProperty:

JSP.5.2 <jsp:setProperty>
The usual bean introspection is done to discover what properties are present, and, for each, its name, whether it is simple or indexed, its type, and the setter and getter methods. Introspection also indicates if a given property type has a PropertyEditor class.
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!