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

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
i have a curiousity regarding "jsp:useBean" tag. When we have to import classes for using "jsp:useBean" tag then why don't we make the objects straight away using that class constructor. Is that something to do with scope?Also are these objects created at compile time itself ? Kindly explain to me in detail. Thanks in advance
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure what you asking in your first question. But, since the bean can be in any scope, it can't be set/created at compile time. In fact, the JSP may not even need to ever create the bean being used. It may have been constructed and stored in a context by some Servlet during initialization much earlier.
 
Sudeep Singh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nathaneil,
Actually i wanted to know the difference between object of a bean created by normal method i.e.(using new()) and by using jsp:useBean tag.if no difference is there then why do we at all use jsp:useBean tag?
 
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
jsp:useBean does more than create an instance of the class. If it finds a bean with the specified name already in the specified scope, it doesn't create a new instance at all -- it just hooks up the existing bean to the scrpting variable. When an instance is created, it is placed in the specified scope.
This isn't anything you could not do with a scriptlet on the page, but is handier and helps keep Java scriptlets out of the page.
 
Sudeep Singh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks everyone for your help
reply
    Bookmark Topic Watch Topic
  • New Topic