GeeCON Prague 2014*
The moose likes JSP and the fly likes inheritance works differently in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "inheritance works differently in JSP" Watch "inheritance works differently in JSP" New topic
Author

inheritance works differently in JSP

Ramkumar Subburaj
Ranch Hand

Joined: Sep 07, 2007
Posts: 83
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 ]

SCJP 1.5, SCWCD 1.4.
Hanging between Web Services and EJB
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

"Ramkumar",
Please check your private messages.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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 ]
 
GeeCON Prague 2014
 
subject: inheritance works differently in JSP