Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

page 416

 
Nikhil Jain
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<jsp:useBean id="person" type="foo.Employee">
<jsp:setProperty name="person" property="name" value="fred" />
</jsp:useBean>

What happens if the servlet code looks like;
foo.Person p = new foo.Employee();
p.setName("Evan");
request.setAttribute("person", p);

This is the question on page 416 of HFS

My questio is, that in usebean we mention type to be "foo.Employee"
but in servlet we have type foo.Person... is this not an error..

please reply
 
Amit Tayal
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shashank
Even though the reference type is Person in servlet but the object is of type of Employee.
So, you can mention reference type as Employee in usebean.

Amit
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!