I'm trying to use static variables into a JSP page (with Tomcat) but I get strange errors...isn't it possible to declare static variables into JSP pages?
As far as i know, the jsp is translated by servlet engine into <some class depends upon the jsp file name>._jspService() method. I think we cannot have static variable declarations in any method in java.
Please correct me if i am wrong.
Yes it's sure, in Java you cannot declare static variables
into methods, so when JSP are built it seems they're all placed inside "service", so that's the problem...
Anyway I was investigating about bean properties, maybe it's possible to achieve a static-like behaviour setting
the bean scope as "application" in this case the bean properties will persist between clients....
hey there... try this in a new jsp file called static.jsp:
static int counter = 0;
out.print("I've been hit: " + counter + " times!");
when I am declaring statement as above shown. then jsp page showing errors that ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY are undefined variables. how to solve this problems. please send a mail to sngolla at rediffmail dot com.