You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Tommy Pham <to...@yahoo.com> on 2009/04/20 04:00:57 UTC

Iterate LinkedHashMap gives HTTP 500 in a JSP (NPE)

Hi,

I have a problem iterating a LinkedHashMap<Integer, Object> lhmObject. 
The lhmObject.size() gives correct size and lhmObject.keySet().toString gives the correct values.
However, if I try iterate the object with lhmObject.keySet() with an empty loop:

for (Integer key : lhmObject.keySet() ) { }

or

for (Iterator it = lhmObject.keySet().iterator(); it.hasNext(); ) { }

I get a HTTP 500 - NullPointerException in the JSP page, which has java.util.* and appropriate <package.Object> for import.
Has anyone seen this before?

Tomcat 6.0.18
JDK 1.6u4
Win03R2 x86

TIA,
Tommy

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Iterate LinkedHashMap gives HTTP 500 in a JSP (NPE)

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tommy,

On 4/19/2009 10:00 PM, Tommy Pham wrote:
> Hi,
> 
> I have a problem iterating a LinkedHashMap<Integer, Object> lhmObject. 
> The lhmObject.size() gives correct size and lhmObject.keySet().toString gives the correct values.
> However, if I try iterate the object with lhmObject.keySet() with an empty loop:
> 
> for (Integer key : lhmObject.keySet() ) { }
> 
> or
> 
> for (Iterator it = lhmObject.keySet().iterator(); it.hasNext(); ) { }
> 
> I get a HTTP 500 - NullPointerException in the JSP page, which has java.util.* and appropriate <package.Object> for import.
> Has anyone seen this before?

Strange. Can you post the stack trace? Also, can you create a minimal
test case that fits into a single JSP so we can play with it?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAknt4PoACgkQ9CaO5/Lv0PDpQACdEacJsacch1L41Jv1kCNq6ZMT
pAQAn1Alu2FrXSZcQFOkucVeGWym5jtf
=Fl7B
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org