My GWT application needs to store cookies and I found that I should
use Cookies.setCookie(...) (from com.google.gwt.user.client.Cookies).
These calls to setCookie are performed by a service at some time by my
RemoteServiceServlet. These calls to setCookie make the call fail on
the client side.
So my question is WHY ? I have read somewhere that cookies are
transfered on the HTTP header so I wonder what the
Cookies.setCookie(...) really does. When can I set cookies and what is
the right way to achieve it?
If you have any idea or can provide interesting material, just let me
know.
Sincerely,
Olivier MATT
Cookies.setCookie and Cookies.getCookie are light sugar over
javascript's cookie setting and getting methods.
Hence your statement that they 'fail' is a bit weird. How are they
failing?
(There are two ways to set/get cookies; one is through HTTP headers,
the other is through javascript. GWT's cookies class uses javascript.
This is almost always better for both security and performance, and
it's far less complicated for GWT at least, to do it that way).
More info on javascript cookie access here: http://www.quirksmode.org/js/cookies.html
Here's what I get in the server logs :
[WARN] StandardContext[]Exception while dispatching incoming RPC call
java.lang.UnsatisfiedLinkError:
com.google.gwt.user.client.Cookies.setCookie(Ljava/lang/String;Ljava/
lang/String;JLjava/lang/String;Ljava/lang/String;Z)V
at com.google.gwt.user.client.Cookies.setCookie(Cookies.java:64)
at com.google.gwt.user.client.Cookies.setCookie(Cookies.java:49)
at
xft.oli.test.server.TaskServiceImpl.OpenConnection(TaskServiceImpl.java:
118)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:
281)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:
167)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
com.google.gwt.dev.shell.GWTShellServlet.service(GWTShellServlet.java:
248)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
237)
That's trully strange. It seems that many other GWT users have been
faced to the same problem and they never got an answer on this group.
Any idea?
read the 'getting started guide'. good luck!