• 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

useBean default scope

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey all,

On page 355 of HFSJ 1.4, it states "If you don't specify a scope in either the <jsp:useBean> or <jsp:getProperty> tags, the container uses the default of "page".

However, on page 360, it gives an example:
<jsp:useBean id="person" type="foo.Person" class="foo.Employee">
<jsp:setProperty name="person" property="*" />
</jsp:useBean>

and then describes the * as iterating through all the REQUEST scope parameters searching for a match to the bean's propteries.

Isn't this a contradiction? Shouldn't you have to specify the scope="request" in the useBean?

Thanks
Daniel
 
Daniel Spritzer
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, on the same topic.. I'm assuming the "*" matches all the values based on the class, and not the type?

So for example, if foo.Person (the type) had only one property, but its child class foo.Employee (the class) had two properties, the * would search the request for TWO properties.
[ April 27, 2008: Message edited by: Daniel Spritzer ]
 
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

Isn't this a contradiction?


No. First of all, getProperty/setProperty have no scope attribute, so you can forget about it. What HFSJ says is that the default scope for useBean will be "page". That's all. The "*" in the "property" attribute of setProperty has nothing to do with this. What it does is look into the request parameters (not request scope parameters), and set the values in the bean. You are mixing request parameters and request attributes.

its child class foo.Employee (the class) had two properties, the * would search the request for TWO properties.


No, it's the other way around. The container uses the request parameters, and set their value into the bean, if possible. If you have a request looking like "/SetUser?name=bob&age=24", the container will try to call setName and setAge, using proper type conversion if necessary.
 
Daniel Spritzer
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Excellent clarification. Thanks for the prompt response.

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