• 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

<jsp:useBean>

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


code inside jsp:useBean is conditional means .. what?? I didn;t understand this..
This is in chapter 8 and page no: 352 inHFSJ
Please clarify/....
 
Ranch Hand
Posts: 220
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If there is no person bean in request scope than the code inside <jsp:useBean tag executed(<jsp:setProperty) and it first create a new person bean in the request scope then set its name property to Fred

However on the other hand, if there is a person bean in the request scope ><jsp:setProperty is not
executed!
So this means ><jsp:setProperty works conditionally based on person bean existence in the scope which you defined in <jsp:userBean tag.

To conclude, if you use a body in <jsp:useBean than the bean existence is important for the behaivor of tag inside <jsp:useBean.
 
Balaji Bang
Ranch Hand
Posts: 182
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok if I want to see this practically...
How can we say that bean object is in request scope or it is not in request scope........
Please explain???


 
Tuna Töre
Ranch Hand
Posts: 220
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can put it in request scope by an servlet

yourpage.jsp which cotains



Below code should be set in a servlet doGet() or doPost() method and should be redirected to yourpage.jsp



You can call servlet with a html link in a regular html page



There can be another solutions also The above code works for the bean which exists.
 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hii,

one small doubt.. now if i set the person bean in request scope.. setProperty will not work right?? when i use getProperty it will result in null is it??

please confirm.
 
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No .. that is not the way it works...

If person bean dosen't exits then only <jsp:setProperty> tag executes and repleces the existing property. But by the example mention above it sets the person bean in the request scope, so <jsp:setProperty> not executes..

But if you use <jsp:getProperty> which is not inside the <jsp:useBean> tag (not based on condition) it executes and get you the value of the mention property, in this case value of name property, if it got some value. means existing value of the name property.

Hope this help you
 
sravanthi pulukuri
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
yes i got it.. based on the above example,see it has bean object set in request scope so setProperty doesnt not execute ,getProerty will give the value of name.. in this case it has no value it will be null.

correct me if iam wrong.
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes !!! you got the point

best of luck AND keep posting
reply
    Bookmark Topic Watch Topic
  • New Topic