package ezj.test;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class cookietest extends HttpServlet
{
    /**
                 * Processes in and out streams from the Servlet service routine.
     * @param req the HTTP request in stream
     * @param res the HTTP response out stream
                 **/
        public final void service(final HttpServletRequest req, final
HttpServletResponse res)
        {
            try
            {
                Cookie c = null;
                Cookie[] c1 = req.getCookies();
                int old = 0;
                if (c1 == null)
                    {
                        c = new Cookie("servletcookie","1");
                        c.setVersion(1);
                        c.setMaxAge( 10000);
                            c.setPath("/ezj.test.");
                        c.setDomain("ezwebtools.com:2020");
                        c.setComment("test");
                        res.addCookie(c);

                    }
                else
                    {
                        for (int i = 0; i < c1.length; i++)
                            {
                                c = c1[i];
                                old = Integer.parseInt(c.getValue());
                                c.setValue(String.valueOf(old + 1));
                                c.setVersion(1);
                        c.setMaxAge( 10000);
                            c.setPath("/ezj.test.");
                        c.setDomain("ezwebtools.com:2020");
                        c.setComment("test");


                                res.addCookie(c);

                            }
                    }
                        Cookie c2 = new Cookie("gabe","345");
                        c2.setVersion(1);
                                res.addCookie(c2);

                                res.setContentType("text/html");
                                PrintWriter pr = res.getWriter();
                                for (Enumeration en =
req.getParameterNames();en.hasMoreElements();)
                                {
                                        String ps = (String)en.nextElement();
                                        pr.println(ps + " PARAMS " + 
req.getParameter(ps));
                                }
                                pr.println("HELLO WORLD - " + old);


        }
        catch (Exception e)
        {
                                                e.printStackTrace();

        }
    }



}

Won Yong Lee wrote:
>
>  $)CAnyone know How I can I set Cookie Info ?
>
> Thanks.
> ----------------------------------------------------------------------
> Won-Yong Lee
>
> Alliance Technology Services                 tel:82-2-369-9291
> Oracle Korea, Ltd.                           fax:82-2-369-9405
>
> 5th. fl. Daehan Investment Bldg.
> 27-3, Yoido-dong Youngdeungpo-gu  , Seoul korea
> -----------------------------------------------------------------------
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff JSP-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to