aspose file tools*
The moose likes JSP and the fly likes jsp:useBean tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp:useBean tag" Watch "jsp:useBean tag" New topic
Author

jsp:useBean tag

Sudeep Singh
Greenhorn

Joined: Jan 27, 2004
Posts: 6
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

Joined: May 29, 2003
Posts: 1258
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.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Sudeep Singh
Greenhorn

Joined: Jan 27, 2004
Posts: 6
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

Joined: Jan 10, 2002
Posts: 60994
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sudeep Singh
Greenhorn

Joined: Jan 27, 2004
Posts: 6
Thanks everyone for your help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp:useBean tag