tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ed Abrams <>
Subject Slightly off-topic question: JSPs and static Members
Date Thu, 04 May 2000 17:02:31 GMT

I apologize for the slightly off-topic post.  But I am having trouble, and
this is the most active list of intelligent java programmers that I
currently know of :)

An outer class is a class that is not itself bounded by anything other than
a package definition.  An inner class is any class that is declared within
the bounds of an enclosing block.  A *local* class is a special case of an
inner class: it is a class specified within the boundaries of a local block,
such as a method.

Now, here is what I can gather from the documentation about these classes:

1.  Outer classes can have static members
2.  Inner classes cannot have static members
3.  Inner classes can be declared static, at which point they become
equivalent to outer classes.
4.  Local classes can only access local variables that have also been
declared final (because of synchronization problems)

But I'm hugely confused.  I can use an include command jsp:include and
include a file like this

class a {
	public static final b = "hi";

This does *not work* using jdk1.1.7, and *does work* using jdk1.2.2.

Now, the JSP gets compiled in such a way that this class becomes a *local
class* of a jsp service method (I think it's the service method, but it
might be some other method; at any rate, it *is* local).  I get why this
doesn't work in jdk1.1.7.  Why does it work in jdk1.2.2?  Wahnsinn!

Further, if I try to break this class out as an outer class using the static
keyword, with *either* jdk the compiler complains that you can't do that
(literally, the error is that the previous line breaks with 'expected }' and
the following line with 'static: expected statement').  Nested classes *can*
be declared static (or so says the inner classes definition); is it the case
that local classes *cannot*?  Wahnsinn!

Please, if anyone happens to know, I'd appreciate it.


View raw message