tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mason Jones <ma...@clipshow.com>
Subject Re: response.addCookie() problem
Date Tue, 08 Aug 2000 21:37:19 GMT

Thanks for the suggestion on this. It actually turns out that
what I was doing was in working, but when I used a page
outside my webapp to display the cookies, they weren't
showing up. I'm still not sure why that is, since the cookies
should obviously be tied to the domain name, not the webapp.

(I've got a simple little page to display cookies which uses
PHP, but it's not seeing the cookies that are being set by the
tomcat servlet...weird. Anyone have ideas why this is?)

Thanks for the help.

Steve Weiland wrote:
>This works.
>
>
>import java.io.*;
>import javax.servlet.*;
>import javax.servlet.http.*;
>
>public class CookieThing extends HttpServlet
>{
>
>     public void doGet(HttpServletRequest request, HttpServletResponse
>response)
>         throws IOException, ServletException
>     {
>
>         response.setContentType("text/html");
>         PrintWriter out = response.getWriter();
>
>         response.addCookie( new Cookie("foo", "bar") );
>         response.flushBuffer();
>
>         RequestDispatcher rd
>             = getServletContext().getRequestDispatcher(
>"/thePageThatShowsTheCookie.jsp"  );
>
>         rd.include(request, response);
>         out.close();
>
>     }
>
>}
>
>/***************************/
>Cookies:
><% Cookie c[] = request.getCookies(); for (int i = 0; i < c.length; i++) { 
>%> name: <%= c[i].getName() %> value: <%= c[i].getValue() %>
><% } %>
>
>Tom Samplonius wrote:
>
> > On Mon, 7 Aug 2000, Mason Jones wrote:
> >
> > > Hello, all... I'm doing something pretty straightforward, trying
> > > to add a cookie to a servlet response before doing a redirect
> > > to a jsp page. But the cookie's simply not being set. Hope
> > ...
> >
> >   This has been discussed before.  I don't believe that browsers will
> > accept an cookie and a redirect in the same response.
> >
> > Tom


________________________________________
   Mason Jones              mason(at)clipshow.com
   Director of Software Development
   ClipShow, Inc.            www.clipshow.com
   (650) 696-3164           fax (650) 696-3267

Mime
View raw message