• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp:useBean tag

 
Sudeep Singh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65217
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks everyone for your help
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic