File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "doubt in JAVA beans" Watch "doubt in JAVA beans" New topic

doubt in JAVA beans

Senthil Nathan.s

Joined: Jan 04, 2006
Posts: 11
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"/>
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();

ii) foo.Employee p= new Foo.Employee();

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é

Joined: Nov 24, 2005
Posts: 14688

[416] Be the Container Answers;

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

Joined: Jan 04, 2006
Posts: 11
thankyou for your reply
I agree. Here's the link:
subject: doubt in JAVA beans
It's not a secret anymore!