Hi,

Placing Cookies in the Response Headers
The cookie is added to the Set-Cookie response header by means of the
addCookie method of HttpServletResponse. Here's an example:
  Cookie userCookie = new Cookie("user", "uid1234");
  response.addCookie(userCookie);

Reading Cookies from the Client
To send cookies to the client, you created a Cookie then used addCookie to
send a Set-Cookie HTTP response header. This was discussed above in section
. To read the cookies that come back from the client, you call getCookies on
the HttpServletRequest. This returns an array of Cookie objects
corresponding to the values that came in on the Cookie HTTP request header.
Once you have this array, you typically loop down it, calling getName on
each Cookie until you find one matching the name you have in mind. You then
call getValue on the matching Cookie, doing some processing specific to the
resultant value. This is such a common process that the following section
presents a simple getCookieValue method that, given the array of cookies, a
name, and a default value, returns the value of the cookie matching the
name, or, if there is no such cookie, the designated default value.

Follow this URL for good understanding of storing and retrieving values from
cookie.
http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/

If the browser is cookie disabled, you can use response.encodeURL("url"), so
that the session id is binded with the url and server can identify the data
respective to the session.

krish
----- Original Message -----
From: anderson <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 04, 2000 8:45 PM
Subject: Cookies


> Hi,
>
> How can I get if the browser is able to receive cookies ?
> If the cookies options in the browser is disable, the session beans
> works ?
>
> thanks
> []s
> anderson
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to