• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

inheritance works differently in JSP

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at the following code:

There are two classes: an abstract Person and Employee class.
The Employee class extends Person class.
The Person class has two methods: getName() and setName(String)
The Employee class has two Methods: getEmpID() and setEmpID(int)

As per the above code, the "username" reference is of type Person and refer to an Employee object.

so using the "username" reference, we can call only the methods from Person class because while compiling, JAVA looks at the reference type.

But in the above code, I have called the classes from the Employee class using the Person reference and it works. see the following code

<jsp:setProperty name="username" property="*"/>
<jsp:getProperty name="username" property="empID"/>

Can anyone clarify this concept.

Thanks,
Ramkumar
So only


[BPSouther: Added code tags]
[ September 07, 2007: Message edited by: Ben Souther ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Ramkumar",
Please check your private messages.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSP uses reflection to locate the methods in your beans.

I know this is in the JSP spec but I'm not able to locate it quickly.
[ September 07, 2007: Message edited by: Ben Souther ]
reply
    Bookmark Topic Watch Topic
  • New Topic