• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

inheritance works differently in JSP  RSS feed

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • 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 Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Ramkumar",
Please check your private messages.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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 ]
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!