Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

page 416  RSS feed

 
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!