Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt in JAVA beans

 
Senthil Nathan.s
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have one doubt in JAVAbeans from HFSJ book in scriptfree pages chapter.
This question occcurs inbetween the chapter.

Question:<jsp:useBean id="person" type="Foo.Employee">

<jsp:setProperty name="person" property="name" value="fred"/>
</jsp:useBean>
Name is :<jsp:getproperty name= "person" property="name"/>


Now what will happen if this jsp page comes after following servlet

i)Foo.Person=new Foo.Employee();
p.setName("evan");
request.setAttribute("person",p);


ii) foo.Employee p= new Foo.Employee();
p.setName("evan");
request.setAttribute("person",p);

Employee is the concrete class and it inherits Person class.Person is an abstract class.

Now the answer given in the book is
i)will not evaluate because the attribute is in request scope but the useBean tag searches in the page scope.



ii)This works fine.


I can understand the first answer but i expect the same answer for the ii) one also but why does it evaluates fine.Can anyone explain me this.....
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.oreilly.com/catalog/headservletsjsp/errata/headservletsjsp.confirmed

[416] Be the Container Answers;
 
Senthil Nathan.s
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thankyou for your reply
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic