• 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 action

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

can anyone please
<jsp:usebean id="what shud be the value here??" the name of the attribute which we defined in the servlet class ??and will this create the bean object?>
 
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
Why are you even using <jsp:useBean> in the first place?

If you have set the scoped variable in the servlet controller, you can just access it by name directly.

For example, if in your servlet controller you wrote:
You can access this in the JSP via: ${message}

The same thing works for objects like beans. If you name the scoped variable myBean, for example, and it has a property accessor such as getWhatever(), that property can be accessed via: ${myBean.whatever}

The useBean action does not need to be used to enable such access.
 
geet kaur
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no i am just going through the scriptless jsp!!(head first) just wanted to know what exactly is happening behind
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With JSP the tags get translated into java code

<jsp:useBean id="myBean" class="com.mypackage.MyBean"/>

gets roughly translated into java as



So you get a scriptlet variable declared on the page.
If the value already exists as an attribute, it will use that value, otherwise it creates a new object.
Full details available in the jsp reference

 
The City calls upon her steadfast protectors. Now for a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic