In JSP,
 
<%
// Adding Cookie(name1 = value1)
Cookie cookie = new Cookie("name1", "value1");
cookie.setPath("/");
response.addCookie(cookie);
 
// Getting Cookie(name1)
Cookie[] cookies = request.getCookies();
String value = "";
if (cookies != null)
{
    for (int i=0 ; i<cookies.length ; i++)
    {
        if (cookies[i].getName().equals("name1"))
        {
             value = cookies[i].getValue();
             break;
        }
   }
}
return value;
%>
 
from acidzazz ^!^;
 


 
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference [mailto:[EMAIL PROTECTED]]On Behalf Of James & Sue Ann Birchfield
Sent: Wednesday, December 22, 1999 7:03 AM
To: [EMAIL PROTECTED]
Subject: Re: Writing cookie in jsp

I don't have a code snippet available this second, but you can read/write cookies using the request/response streams.  Look at the API for the Cookie class...
 

==================================================================
James M. Birchfield                               646 Howards Loop
Software Engineer                                    Annapolis, MD
[EMAIL PROTECTED]                               (410) 897-5994
                  http://www.proteus-technologies.com
==================================================================

 
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference [mailto:[EMAIL PROTECTED]]On Behalf Of Mike Begeman
Sent: Tuesday, December 21, 1999 3:58 PM
To: [EMAIL PROTECTED]
Subject: Writing cookie in jsp

Until now, I have always used javascript to write cookies.  Does anyone have a code snippets (or suggestions on how) to write and delete cookies using JSP and/or a javabean?
 
Mike Begeman
Digital Prairie Systems, Inc.
 
 

Reply via email to