Cookie

Shivani <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.