Two Laptop Bag*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes doubt in JAVA beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "doubt in JAVA beans" Watch "doubt in JAVA beans" New topic
Author

doubt in JAVA beans

Senthil Nathan.s
Greenhorn

Joined: Jan 04, 2006
Posts: 11
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.....


with regards<br />s.senthilNathan<br />PH:9819194691
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

http://www.oreilly.com/catalog/headservletsjsp/errata/headservletsjsp.confirmed

[416] Be the Container Answers;


[My Blog]
All roads lead to JavaRanch
Senthil Nathan.s
Greenhorn

Joined: Jan 04, 2006
Posts: 11
thankyou for your reply
 
Don't get me started about those stupid light bulbs.
 
subject: doubt in JAVA beans
 
Similar Threads
Is this an error in HFSJ ??
servlet & jsp related doubt
useBean doubt
Head First Servlets and JSP:SCWCD Question
HFSJ doubt :Pg:356