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