W3C home > Mailing lists > Public > www-jigsaw@w3.org > September to October 1997

ClassCast Exception in Cookie.saveCookie

From: Payam Mirrashidi <payam@cybernetic.triptonite.com>
Date: Thu, 04 Sep 1997 01:10:29 -0700
Message-ID: <340E6CF4.A499FCFD@cybernetic.triptonite.com>
To: www-jigsaw@w3.org
I've been trying to get some of my servlets working with the new beta1
release
and I'm running into a problem when I try to save a cookie using the
Cookie.saveCookie() call. My servlets and the Sun "Counter" demo servlet

shipped with jeeves both respond with the following error whenever
saveCookie is called.
All of these servlets work fine with srun and the sun server.

The output in the web browser is:
Servlet has thrown exception:java.lang.ClassCastException:
w3c.jigsaw.servlet.JigsawHttpServletResponse

The stack trace is:
        at sun.servlet.http.Cookie.saveCookie(Cookie.java:365)
        at JASServlet.generateNewCookie(JASServlet.java:258)
        at JASServlet.doPost(JASServlet.java:86)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:278)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:330)
        at
w3c.jigsaw.servlet.ServletWrapper.perform(ServletWrapper.java)
        at w3c.jigsaw.http.httpd.perform(httpd.java)
        at w3c.jigsaw.http.Client.processRequest(Client.java)
        at w3c.jigsaw.http.Client.startConnection(Client.java)
        at w3c.jigsaw.http.socket.SocketClient.run(SocketClient.java)
        at w3c.util.CachedThread.run(ThreadCache.java

I modified the Jeeves 1.0 Counter.java file like this:
System.err.println("Before saveCookie");
 try
   {
     c.saveCookie (res);
   }
 catch (Exception e)
   {
     e.printStackTrace();
     throw new ServletException("Couldn't save Cookie");
   }
 System.err.println("After saveCookie");

and got this result:

Counter: init
Before saveCookie
java.lang.ClassCastException:
w3c.jigsaw.servlet.JigsawHttpServletResponse
        at sun.servlet.http.Cookie.saveCookie(Cookie.java:365)
        at Counter.doGet(Counter.java:151)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:252)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:330)
        at
w3c.jigsaw.servlet.ServletWrapper.perform(ServletWrapper.java)
        at w3c.jigsaw.http.httpd.perform(httpd.java)
        at w3c.jigsaw.http.Client.processRequest(Client.java)
        at w3c.jigsaw.http.Client.startConnection(Client.java)
        at w3c.jigsaw.http.socket.SocketClient.run(SocketClient.java)
        at w3c.util.CachedThread.run(ThreadCache.java)

My first thought was that the saveCookie didn't like the
JigsawHttpServletResponse object I'm getting from jigsaw's but
JigsawHttpServletResponse implements HttpServletResponse and that is
what saveCookie wants. My next guess was that the JSDK saveCookie
implementation really wanted an HttpResponse for some reason. Trying to
cast
the jigsaw version to HttpResponse didn't work though.

Can someone else verify this problem? Or does anyone have a workaround?

P
Received on Thursday, 4 September 1997 04:12:31 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 9 April 2012 12:13:26 GMT