hi shri,

The bean Object access scope will be limited to the page
where it has been instantiated regardless of the bean scope.

But when you instantiate the object in the subsequent page
the creation of the object will be decided upon the scope
of the object.for example you are trying to create the object
again which is in the scope 'session' then you will get the
same reference.

In case of singleton ,provide a static method to get the
object of the class and have the implementation as follows,

create the object of it's own when it does not exists in
the JVM and return the reference.Make sure you are having
the constructor as private.

Then call the static method of the class to get the reference
instead of using usebean tag.

hope this helps,

with regards,
      rathna.


>>Hi,

I have a requirement where I have to store the data in a persistent java
class and then whenever user requires it he can use it. So per session I
want to create only one instance of the class which will be used in
different JSPs.

I want to use Singleton pattern to maintain only one instance per
session. So in any JSP if user wants to create another instance of the
class, the same instance should be returned to the user.

My doubt is, whether the scope of the class object instantiated in a JSP
will be limited to that page only or class object can be accessed if
exists, in subsequent pages also.

Please clarify.
Thanks in advance

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to