Hello David!
DN> Until now I found only one place I can use it. It's an admin page where I am
DN> monitoring our server's current memory usage and memory usage "delta"
DN> between two "events".
DN> There you need some kind of "local", "static" (in C++ terms) variables to
DN> keep track of previous/current memory usage and I found <%! %> a good
DN> shortcut for doing it.
Well, it's a good place to put static constant data needed by
the page.
For example, it is perfectly reasonalbel to do something like
<%! const java.util.Locale myLoc = new java.util.Locale("ru","RU"); %>
<%! const String choices[] = { "aaa", "bbb", "ccc" }; %>
And if anybody needs to declare some function he will call later
in a scriptlet or in an expression (<%= %>)
it is also apropriate to put it here:
<%!
java.util.Random rand = new java.util.Random();
String generatePassword(){
StringBuffer ret = new StringBuffer;
for (int i=0;i<23;++i) ret.append(
(char)(
Math.floor(rand.nextFloat()*20)
)
);
return ret.toString();
}
%>
Hope I haven't run into any sychronization trouble,
at least the api docs for sun jdk 1.3 say that
java.util.Random is synchronized somewhere inside.
Best regards, Anton Tagunov
===========================================================================
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://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com