• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HFSJ 2nd edition page 420 - Be the Container Answers

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a doubt on the explanation for "Be the Container Answers"

JSP standard action

<jsp:usebean id="person" type="foo.employee" scope = "request">
<jsp:setproperty name="person" property="name" value="fred"/>
</jsp:usebean>
name is<jsp:getproperty name="person" property="name"/>

First question is
Servlet code:
foo.Person p = new foo.employee();
p.setName("evan");
request.setAttribute("person",p);

And the answer says "Fails at request time! The person attribute is stored at request scope, so the <jsp:usebean> tag won't work since it specifies only a type "
But, the <jsp:usebean> tag has the scope specified as request. Since the scope specified in the tag and the scope where the attribute is stored is "request" why shouldn't the usebean tag work?
Can anybody please help clarify?
[ April 05, 2008: Message edited by: R Nellika ]
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Nellika,

I found your "Be the Container Answers" at page 416. I dont know which version of book i am using.

In my book, it scope attribute is not specified with jsp:useBean tag. So, by default, it will be page. In that case this answer might be correct.

But this might be a chance that "in the new version of book, they have specified scope, but not corrected the answer".

--Naresh
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic