Forums Register Login

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

+Pie Number of slices to send: Send
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,
Matthias
[ November 12, 2008: Message edited by: Matthias De Scheerder ]
+Pie Number of slices to send: Send
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.
Being a smart alec beats the alternative. This tiny ad knows what I'm talking about:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 632 times.
Similar Threads
Standard actions - doubt in HFS - page 414
doubt on jsp:useBean tag
doubt in scriptless JSPs
useBean doubt
Doubt in use bean
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 18:42:31.