Shivani, if your 2nd cookie is not getting rejected it should definitely be in the request. Also, pls note here that more than one Cookie can be set and hence , if you are saying ">String cookie1=cookies[0].getName();", it is only going to access the first one in the list. Hence, as someone suggested, pls iterate thro the Cookie array and you will get to see all those that are set.
-----Original Message----- From: Shivani [mailto:[EMAIL PROTECTED] Sent: Saturday, February 15, 2003 5:25 PM To: [EMAIL PROTECTED] Subject: Re: Cookie instead of: Cookie myCookie= new Cookie("cookie_test ", "22"); now if i put: Cookie myCookie= new Cookie("cookie_test2 ", "24"); should it created a new cookie with that new name. if yes, i try to execute the servlet but it shows the 1st cookie name only. is this the supposed to be behaviour? not understanding here.. -----Original Message----- From: A mailing list for discussion about Sun Microsystem's Java Servlet API Technology. [mailto:[EMAIL PROTECTED] Behalf Of Eric Noriega Sent: Saturday, February 15, 2003 11:09 AM To: [EMAIL PROTECTED] Subject: Re: Cookie What do you mean "change the name of the cookie?" Are you doing an res.addCookie() with another name? Shivani wrote: >HI, > >i am setting cookie parameters and retriving them in same servlet for >testing cookie class. > >however, if i change name of cookie i have set and run this servlet, it >doesn't show me new name always. why is it anyidea? where should i find out >the new name in browser where it's put. pls. help! >thanks! >--------------------------------- >example: > public void doGet(HttpServletRequest req, HttpServletResponse res) > throws ServletException, IOException > { > >//create a cookie and place it on the browser: >Cookie myCookie= new Cookie("cookie_test ", "22"); > > PrintWriter out = res.getWriter(); > res.setContentType("text/html"); > > res.addCookie(myCookie); > >//get the cookie: >Cookie[] cookies = req.getCookies(); > >//asign name of 1st cookie to a string called cookie1 >String cookie1=cookies[0].getName(); >out.println("the name of cookie is:"+ cookie1); > >} >------------------- > >output is: >the name of cookie is:cookie_test > >so if i change the name, it's not reflected in this output, why? am i doing >this right? > >___________________________________________________________________________ >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 ___________________________________________________________________________ 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