-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Jin,
Qiao Jin wrote:
> Here is an example, a menu header JSP included in various pages:
>
> <%!
> class MenuItem {
> String pageURL;
> String text;
>
> MenuItem(String url, String t) {
> this.pageURL = url;
> this.text = t;
> }
> }
>
> static MenuItem[] menu = new MenuItem[] {
> new MenuItem("page1.jsp", "Home"),
> new MenuItem("page2.jsp", "Info"),
> new MenuItem("page3.jsp", "Contact")
> };
>
> %>
Since you have static members (MenuItem[] menu), you must use a static
inner class (MenuItem). Just change your declaration of the MenuItem
class to be static.
'menu' is static in the test_jsp class, which means that it is
initialized at class load-time (before any instances of the class have
been created). MenuItem is not accessible until after an instance of
test_jsp has been created, so you have a paradox. The solution is to
make them both static. Or make them both non-static. Whichever you prefer.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkl/wBEACgkQ9CaO5/Lv0PA/aQCfRMo+aplth2RJmddR1VP4DTgM
3goAn0WNvcB6ZE14aezeazQTEA9I4KcP
=2LDa
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]