Hi,
If you can read the cookies from the jsp/servlets you've added from javascript,
there may be some reasons.

I think,
1. The path of Cookie : if you didn't set the path of cookies, then you could only see 
the cookies
    in the same path the cookie-writing page resided in.

2. The order of javascript and JSP in one page : JSP is executed first, then 
javascript executed with generated HTML.

3. Browser BUGs : ...

4. The JSP/Servlet engine BUGs : ...

The thoughts of mine are so incomplete...

from acidzazz ^!^;




-----Original Message-----
From: Praveen Kumar S . [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 23, 1999 4:08 PM
To: [EMAIL PROTECTED]
Cc: Mike Begeman; acidzazz; Siva Surya Kumar V
Subject: RE: Writing cookie in jsp



Hi,

sorry to join in late, but as i went thro' the mails,  i found i could
contribute a similar problem i had,

I am doing some assumptions,

you are mixing JSP and javascript cookies, if i am wrong pls correct me....

"this will not work........"

why, i dont know, i have had an experiance once, that when i try to add
cookies from javascript, i cannot read it from the jsp/servlets api....

is this a drawback or a security feature is open for discussion, but when
you set the cookie in a javascript, the cookie cannot be read in the
JSP....????????

well you can actually set(response) the cookie in jsp itself, and
read(request) from it.

so if you can actually clear me up on the problem at hand maybe i can help
out,
> -----Original Message-----
> From: acidzazz [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, December 23, 1999 11:29 AM
> To:   [EMAIL PROTECTED]
> Subject:      Re: Writing cookie in jsp
>
> Hi Surya,
>
> As you know, javascript is executed on client side, against JSP(or
> Servlet) on server side.
>
> Then, there is no way to add the value of a textfield to the cookie using
> JSP in one session.
>
> But if you decide to use javascript to add the value to the cookie, you
> can.
>
> As a reference, you can write JSP code that generates javascript code in
> JSP 1.0 spec.
> ex)
> <%@ page language=javascript %>
> <%
>     ... javascript code ...
> %>
>
> I recommend for you to post the textfield value(using form/action) to JSP
> that handles the value.
> ex)
> In page1.jsp
>     :
> <form action="/writecookie.jsp" method="post">
> <input type=text name="name1" size=20 value="">
> </form>
>
> In writecookie.jsp
> <%
> String value1 = request.getParameter("name1");    // getting the value of
> textfield
>
> Cookie cookie = new Cookie("name1", value1);    // adding cookie
> cookie.setPath("/");
> response.addCookie(cookie);
>      :
> %>
>
> I hope it will help you.
>
> from acidzazz ^!^
>
>
>
>  -----Original Message-----
> From: Siva Surya Kumar V [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, December 23, 1999 12:56 PM
> To: acidzazz
> Subject: Re: Re: Writing cookie in jsp
>
>
>
>       HI ...
>
>           Its a good example.
>           But i have a BIG probelm.
>           In the line :
>
>
>       Cookie cookie = new Cookie("name1", "value1");
>
>
>       If the "value1" is a javascript variable then how should i do it
> ????
>       Mean to say i want to add the value of a textfield to the cookie .
>       How should i do it ???
>       Thanks in advance.
>       Surya.
>
>
>               ----- Original Message -----
>               From: acidzazz <mailto:[EMAIL PROTECTED]>
>               To: [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>
>               Sent: Wednesday, December 22, 1999 6:44 PM
>               Subject: Re: Writing cookie in jsp
>
>               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.
>
>
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to