• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

doubt in page 356 of HFSJ

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
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"/>
</jsp:usebean>
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();
p.setName("evan");
request.setAttribute("person",p);

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.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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 ?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think this is already in the errata, page 416.
 
a fool thinks himself to be wise, but a wise man knows himself to be a fool - shakespeare. foolish tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic