As Andy remarked: the call request.getCookies(); should return null if there are no cookies submitted. This behaviour is specified in the JavaDocs for both the Servlet 2.2 and 2.3 specs. Tomcat 3 was in error and the behaviour has been corrected for Tomcat 4 and later.

HTH,

Jon

Paul wrote:

I hava a JSP application under Tomcat 4.1.24, jdk 1.4, running as service on win2k 
currently in standalone mode.
The default index.jsp page checks for cookie that has not yet been set.
Under Tomcat 3.x (jdk 1.2), this cookie checking does not generate an error; however, 
under Tomcat 4 it generates an HTTP Status 500 exception report, where the root cause 
is given as java.lang.NullPointerException.
If i subsequently run a page which does not check for cookie, that non-cookie checking 
page loads fine; and then the cookie checking page loads fine without any exception 
report.  It is only when the cookie checking page runs FIRST that error message is 
generated.

I am uncertain if this is some sort of jsp error or some sort of Tomcat error.

here is code used to check for cookie, where that cookie does not exist when this code generates error. But then again, that cookie still does not exist when this code works fine (ie, after running a jsp that does not check for cookie) - which is why i am wondering if this has something to do with Tomcat 4, or perhaps how it is configured???

   Cookie[] cookies = request.getCookies();
   for(int j=0; j<cookies.length; j++) {
     cookieName = cookies[j].getName();
     cookieValue = cookies[j].getValue();
     if (cookieName.equals("ex")) {
       xx = cookieValue;  // wher xx is previously defined as a String object
       break;
     }
   }

Any and all help is more than welcome, as i am a bit stumped as to how to begin 
troubleshooting this.
-paul lomack





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to