But surely a Java Bean can't be a singleton (in our typical usage of the
word), because it must have a public default constructor, and
calling <usebean...> on it will not allow you to call the static
XBean.getInstance()
method ? Doesn't making it application scope have the same effect ?
> -----Original Message-----
> From: Ron Chan [SMTP:[EMAIL PROTECTED]]
> Sent: 03 August 2000 18:22
> To: [EMAIL PROTECTED]
> Subject: Re: static initialiser block in JSP page
>
> Hi,
>
> take a look at the Singleton pattern.
>
> ron
>
>
> --- Oren Klichevsky <[EMAIL PROTECTED]>
> wrote:
> > I think that you should approach the problem from
> > another direction.
> > Create a bean that will do all the initilization of
> > the Hashtable on it's
> > instantiation.
> > After that use your bean with the "application"
> > scope within your JSP files.
> > This will assure you that this bean will be
> > inistantiated only one time for
> > the whole application. After doing that you will be
> > able to use all the
> > regular bean syntax of JSP to access it's data.
> >
> >
> > Best Regards,
> > Oren Klichevsky
> > www.mannainc.com <http://www.mannainc.com>
> >
> >
> >
> > -----Original Message-----
> > From: A mailing list about Java Server Pages
> > specification and reference
> > [mailto:[EMAIL PROTECTED]]On Behalf Of
> > Dowd, Brian
> > Sent: Thursday, August 03, 2000 6:12 PM
> > To: [EMAIL PROTECTED]
> > Subject: static initialiser block in JSP page
> >
> >
> > HI All,
> > I'm trying to get a static initializer in my JSP
> > page (such that it will
> > only ever populate
> > a hashtable once in the java file generated).
> > Something *like* this :
> >
> > <%!
> > String code = "X";
> >
> > // static initialiser block to construct
> > hashtable (once ever).
> > static {
> > Hashtable months = new Hashtable();
> > // These values come from the region
> > table in ARM.
> > regions.put("0", "January");
> > regions.put("2", "February");
> >
> > // .... etc
> >
> > }
> >
> > %>
> >
> >
> > <%
> > // Use a month
> > out.println("Jan=" + (String) regions.get("1"));
> >
> > %>
> >
> >
> > It works if I move it out of the <%! .. %> tags and
> > make it a non static,
> > but the
> > point is I want it to be static .... has anyone done
> > anything similar ?
> >
> > Cheers,
> > Brian.
> >
> >
> ==========================================================================
> =
> > To unsubscribe: mailto [EMAIL PROTECTED] with
> > body: "signoff
> > JSP-INTEREST".
> > 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".
> > 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
>
>
> __________________________________________________
> Do You Yahoo!?
> Kick off your party with Yahoo! Invites.
> http://invites.yahoo.com/
>
> ==========================================================================
> =
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> 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".
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