Cookies Additional Information

  • Default behaviour of cookie is that they can remember the client for a single application running on a server, but what if we want to share the cookie across multiple application running on the same server.

  • This can be acheived by modifiying the default behaviour of cookie, by setting the cookie class methods : setPath, setDomain.

   /*javax.servlet.http.Cookie*/
   public void setDomain(String domain)
   public void setPath(String uri)
  • To access clnt info from the cookies?(suppose name of cookie is "clnt_info")

   Cookie[] cookies=request.getCookies();
   if(cookies != null)
      for(Cookie c : cookies)
      if(c.getName().equals("clnt_info"))
         c.getValue();

Last updated