tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Yunusov <>
Subject Re: interesting java.lang.NullPointerException error when first viewing an index.jsp page - refresh once and page loads correctly
Date Sat, 11 Jan 2003 14:52:48 GMT
On Friday 10 January 2003 05:49 pm, Brandon Rodak wrote:
> Paul,
> Here is a link to the Java -
> Thanks again for your help
> Brandon Rodak
> Web Services
> Computer Marketing Corporation
> &

Brandon, the scriptlet in your jsp gets your server's cookies from the client:

Cookie[] cookies = request.getCookies();

but on the initial request, there are no cookies set by your server on any 
given client, so getCookies() returns null in accordance with the servlet 
spec. That triggers a NPE when you try to process the cookies later:

for (int i=0; i<cookies.length; i++) {

Put an "if" statement around your "for" loop to check if cookies is null or 
not and that should fix your problem.


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message