• 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

bean is in 'request' and searching property is in 'page'

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

On page 347 (and on other pages also) of HFS&J, the scope where we are searching for bean object (or where object will be created if not found) is request.

<jsp:useBean id=�person� class=�foo.Person� scope=�request� />

But while getting property, we are not specifying any scope, it means it is page scope (default one).

<jsp:getProperty name=�person� property=�name� />

Then how it is possible to get property, given that bean object is in other scope (that too in higher scope)?

Thanks.

[ May 22, 2006: Message edited by: Bear Bibeault ]
 
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
in getProperty, you refer to which bean you are using, right ? (name="person")
The useBean tag already specifies the scope where the bean is supposed to be, why would you need to specify a scope for getProperty ?
 
Ranch Hand
Posts: 485
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

On page 347 (and on other pages also) of HFS&J, the scope where we are searching for bean object (or where object will be created if not found) is request.

<jsp:useBean id=�person� class=�foo.Person� scope=�request� />

But while getting property, we are not specifying any scope, it means it is page scope (default one).

<jsp:getProperty name=�person� property=�name� />

Then how it is possible to get property, given that bean object is in other scope (that too in higher scope)?


The container will try to find the value for the attrbute
named "person" from one of the scope mentioned below in the same order given below

page
request
session
Applicaton

so the bean object which is placed in request scope is retrieved by the container.
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Parameswaran Thangavel:

The container will try to find the value for the attrbute
named "person" from one of the scope mentioned below in the same order given below

page
request
session
Applicaton

so the bean object which is placed in request scope is retrieved by the container.



Then why the <jsp:getProperty> action has scope attribute???

Thanks.
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Then why the <jsp:getProperty> action has scope attribute???



so that if u already knwo the scope, you put the scope and the container will get it from that, and will not have to search it through all the scopes. This will reduce the work the container has to do
 
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
???
Where did you see that getProperty had a scope attribute ?
There are only two attributes : name and property.

But while getting property, we are not specifying any scope, it means it is page scope (default one).


Why do you think that the default scope is set to page ? Did you read that in HFSJ ? Certainly not. getProperty has nothing to do with scope.
[ May 22, 2006: Message edited by: Satou kurinosuke ]
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Satou kurinosuke:
???
Where did you see that getProperty had a scope attribute ?
There are only two attributes : name and property.


Why do you think that the default scope is set to page ? Did you read that in HFSJ ? Certainly not. getProperty has nothing to do with scope.

[ May 22, 2006: Message edited by: Satou kurinosuke ]



From page 355 of HFS&J:

"If you don't specify a scope in either the <jsp:useBean> or <jsp:getProperty> tags, the container uses the default of "page"."
 
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
Thanks rathi.
According to the jsp specification, there is no scope attribute for getProperty.

Syntax:
<jsp:getProperty name="name" property="propertyName"/>


There's been a thread about this before:
https://coderanch.com/t/168940/java-Web-Component-SCWCD/certification/scope-attribute-HFSJ
[ May 22, 2006: Message edited by: Satou kurinosuke ]
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Satou kurinosuke:
Thanks rathi.
According to the jsp specification, there is no scope attribute for getProperty.

Syntax:
<jsp:getProperty name="name" property="propertyName"/>


There's been a thread about this before:
https://coderanch.com/t/168940/java-Web-Component-SCWCD/certification/scope-attribute-HFSJ

[ May 22, 2006: Message edited by: Satou kurinosuke ]



Thanks Satou.
So it's an error in HFS&J.
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<jsp:getProperty> is an method call that executes on a java bean. <jsp:useBean> creates an object. It needs to know where to store this object - defining its scope. Ideally <jsp:getProperty> should have a scope control, say only searches in certain scope. But it doesn't.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure I agree that it's a "should", but the JSP 2.0 EL solves this "problem" by allowing you to specify the scope within which a reference to a scoped variable is made.

P.S. Please see my response in your other reply regarding your display name.
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
I'm not sure I agree that it's a "should", but the JSP 2.0 EL solves this "problem" by allowing you to specify the scope within which a reference to a scoped variable is made.

P.S. Please see my response in your other reply regarding your display name.



It means, all the HFS&J examples (code) are wrong. Because there, the bean scope is request (most of the time) and scope in <jsp:getProperty> is not specified (so page)...
[ May 28, 2006: Message edited by: rathi ji ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

and scope in <jsp:getProperty> is not specified (so page)...


No, not "so page".

Have you read the JSP Specification section on these actions?
[ May 28, 2006: Message edited by: Bear Bibeault ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic