If the request does not contain any cookies, request.getCookies() returns a null value...Maybe thats why you cant see any println's. If you look into your server logs you just might find a NullPointerException thrown at the line where you've written > System.out.println("(4) The first cookie in the array is: " + > cookies[0].getName());
regards Pramod Nair ----- Original Message ----- From: "Mike Cronin" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, September 18, 2002 1:04 AM Subject: Cookie help... > Hi all, > > I am having a problem with cookies that has me a bit stumped. > > Processing appears to die as soon as I reference the array of cookies. > > In the following example, System.out.println (1) through (3) display fine, > while System.out.println (4) and (5) do not. No errors are thrown, > processing > just stops. > > What am I missing? > > Thanks in advance! > > Mike Cronin > > > -------------------------------------------------------------- > package doccookietest; > > import javax.servlet.*; > import javax.servlet.http.*; > import java.io.IOException; > > public class CookieServlet extends HttpServlet { > > public void init(ServletConfig config) throws ServletException { > super.init(config); > } > > public void doGet(HttpServletRequest request, HttpServletResponse > response) throws ServletException, IOException { > > response.setContentType("text/html"); > > System.out.println("(1) In the CookieServlet doGet now!"); > > // Retrieve an array of cookies from the requesting browser > Cookie[] cookies = request.getCookies(); > > System.out.println("(2) You have retrieved an array of cookies."); > > System.out.println("(3) Prior to referencing the first element of the > array..."); > > System.out.println("(4) The first cookie in the array is: " + > cookies[0].getName()); > > System.out.println("(5) Here is the first line after referencing the > array"); > > } > > public void destroy() { > } > } > > -------------------------------------------------------------- > > ___________________________________________________________________________ > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body > of the message "signoff SERVLET-INTEREST". > > Archives: http://archives.java.sun.com/archives/servlet-interest.html > Resources: http://java.sun.com/products/servlet/external-resources.html > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html > ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html