Not sure if this is what your dealing with, but you can't add a cookie to a
response after any data has been committed to the client since the cookies
have to be included in the response header.  So if "a.jsp" is writing any
data out to the client before including "b.jsp" then you won't be able to
add a cookie to the response.  I believe you should receive something like
an "IllegalStateException" in this case.

Hope this helps,

        -Shawn

-----Original Message-----
From: rit7esyahoo [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 10, 2002 3:41 AM
To: JDJList
Subject: [jdjlist] RE: how can put cookies?


On Mon, 9 Sep 2002 11:25:40 -0700 
Greg Nudelman <[EMAIL PROTECTED]> wrote:

Thanks for answering. I mean: 
1). "a.jsp" has: "<jsp:include page="b.jsp" flush="true" />".
2). "b.jsp" has: 
        Cookie cookie = new Cookie(name, value);
        cookie.setMaxAge(maxAge);
        cookie.setPath("/");
        response.addCookie(cookie);
3).The problem is that this doesn't work.

Thanks again.

> I can not really understand what you're saying... sorry. Can you post some
> code?  
> 
> Here is a couple of points that may help:
> 
> 1)
> jsp: include
> works on the server-side NOT in the browser.  
> 
> 2)
> If the response is not valid in the chained servlets:
> request.getRequestDispatcher("/Jsp/b.jsp").forward(request,response); 
> the request will not be processed and ServletException will likely be
> thrown.
> 
> 3)
> You can TRY to put a cookie through void addCookie(Cookie cookie) 
> Which adds the specified cookie to the response.  NOTE: this does not
> guarantee that browser accepts cookies. 
> 
> 
> Greg
> 
> -----Original Message-----
> From: rit7esyahoo [mailto:[EMAIL PROTECTED]]
> Sent: Monday, September 09, 2002 10:12 AM
> To: JDJList
> Subject: [jdjlist] how can put cookies?
> 
> 
> Hello all:
> 
>       We are developing a wrapper system. So we have a jsp page: "a.jsp"
> that call to another jsp page: "b.jsp"  through an "jsp: include". On
> entering to a.jsp in the navigator, the jsp block call to the included jsp
> page. In b.jsp we have a code to put a cookie throught the "response", but
> the response in b.jsp is not valid, so the cookie is not entered in the
> system ( appearly is a response different from a.jsp response).
> 
>       Can anyone tell the mean i can put the cookie in b.jsp through java
> code, or just get the response on b.jsp?
> 
> Thanks.
> _______________________________________________________________
> 
> Copa del Mundo de la FIFA 2002
> 
> El unico lugar de Internet con videos de los 64 partidos. 
> 
> !Apuntante ya! en http://fifaworldcup.yahoo.com/fc/es/
> 
> 
> To change your JDJList options, please visit:
> http://www.sys-con.com/java/list.cfm
> 
> 
> To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm
> 
_______________________________________________________________

Copa del Mundo de la FIFA 2002

El �nico lugar de Internet con v�deos de los 64 partidos. 

�Ap�ntante ya! en http://fifaworldcup.yahoo.com/fc/es/


To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm

To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm

Reply via email to