Hi
With Tomcat 4.0 I have developed a taglib for visit cookies. The
relevant part of the code is very similar to what you sent:
HttpSession session=pageContext.getSession();
HttpServletRequest
request=(HttpServletRequest)pageContext.getRequest();
HttpServletResponse
response=(HttpServletResponse)pageContext.getResponse();
if(session.isNew()) {
String cValue=getCookie(request.getCookies(),
name).getValue(); // getCookie is an auxiliary function
session.setAttribute(visit, cValue);
}
Cookie cookie=new Cookie(name, getTimestamp());
cookie.setMaxAge(expires);
response.addCookie(cookie);
(this code belongs to a tag libray)
And it seems to work without problems.
Andre de Jesus
Arnaud H�ritier wrote:
>Hi all !!
>
>I face up to a problem concerning the use of cookies in a tag library.
>
>In my tag library I would like to store a cookie on the client.
>I wrote this in the doStartTag method of my tag :
>
> HttpServletResponse httpResponse =
>(HttpServletResponse)pageContext.getResponse();
> Cookie cookie = new Cookie("myCookie","cookie");
> httpResponse.addCookie(cookie);
>
>but when later I retreive the list of cookies, this one is lacking.
>
>I tried to create cookies in my servlet and it works fine.
>
>I don't understand what it can happen !!!
>
>Can't we use cookies from tag libraries ????
>
>my configuration is :
>Tomcat 3.2.3
>AJP1.2
>Apache 1.3.20
>IE5.5
>
>
>Have you any ideas ???
>
>thanks
>
>
>Arnaud HERITIER
>Ing�nieur d'�tudes
>SOPRA. Group
>EAI Consulting
>Tel : +33-1-53-33-44-74
>Email : [EMAIL PROTECTED]
>
>
--
Andr� de Jesus <[EMAIL PROTECTED]>
TEKTIX - Consultoria em Sistemas de Informa��o, L.da
http://www.tektix.com