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 page 356 of HFSJ 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 page 356 of HFSJ" Watch "doubt in page 356 of HFSJ" New topic

doubt in page 356 of HFSJ

swapna rao
Ranch Hand

Joined: Feb 12, 2008
Posts: 53
I have a doubt in <jsp:usebean> tag. when we use <jsp:usebean> it tries to get an attribute defined at the specific scope.If no attributes is present , we can even create new attibute at the specific scope. If we dont specify any scope,default scope is "page".As per my underatstanding,if we define any scope along with <jsp:usebean> and if attribute is not present in that scope it will not search the remaining scopes(request,session.application etc).

In the page 356 of HFSJ an example is given like below:
JSP page:
<jsp:usebean id="person" type="foo.employee">
<jsp:setproperty name="person" property="name" value="fred"/>
name is<jsp:getproperty name="person" property="name"/>

Then 3 quetions were asked in which my first two anwsers match with book answers.
Third questions is:
Servlet code:
foo.employee e=new foo.employee();

Above servlet code sets an attribute in the request scope.How cane the JSp code <jsp:usebean> gets an attribute at the request scope and prints the name value?(Because scope attribute is not defined with <jsp:useban> tag and default scope is "page").
Please help me in understanding this question.

SCJP-88<br />SCWCD-94
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

"swapna d",
Thank you for changing your name, but it still does not fit the Naming Policy requirements. As stated, you can use an initial or initials for the first name if you like (but not the last). Could you please change it again ?

[My Blog]
All roads lead to JavaRanch
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

I think this is already in the errata, page 416.
I agree. Here's the link:
subject: doubt in page 356 of HFSJ
It's not a secret anymore!