Objects of scope "session" are available to more or less anyone within that
session. There's no easy way to guarantee an object that has
session-persistence but is only available within the page -- that would mean
it was double-scoped, available only to the page (scoped for the page) but
hung off the session (scoped for the session).
What's the motive for hiding the scope on a page-by-page basis? I can think
of two:
1. This is a security issue, you're trying to prevent other pages from
accessing the object.
2. You want to have a different session-based singleton for each page. In
this case, you might want to hang a Hashmap off your session and use the
name of the page or some constant key to identify your singleton.
Don't forget threading issues, by the way ...
Regards,
Ben Flaumenhaft
Principal, Sidelight Consulting
http://www.sidelight.com
----- Original Message -----
From: "shrikantv" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 11, 2000 9:01 AM
Subject: Singleton Pattern and JSP
> 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
===========================================================================
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