Are you sure the exception is inside the for loop because i think it should be in c.length call..
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.
Put an "if" statement around your "for" loop to check if cookies is null or not and that should fix your problem.
if(cookies != null) {
for (int i=0; i<cookies.length; i++) {
...
}
}