开发者

How to share cookie between GWT and a Tomcat Webapp?

My situation is as following: On one side I have a webapplication running in tomcat with spring security and sessions handled by tomcat. After authentication against spring, tomcat sets a session cookie in the browser, identifiying me as the user logged in. On the other side I want to develop a GWT frontend, which is running in the integrated jetty server that comes along with the SDK. The GWT app should be able to call resources via AJAX Requests on the tomcat application.

My assumption would have been, that the GWT application is also authenticated using the same cookie as both applications (GWT and tomcat app) are running on the same domain (localhost) with th开发者_开发百科e only difference that GWT uses port 8888 and tomcat 8080.

Unfortunately any request from GWT to the tomcat webapp redirects me to the login page. I tried to set the cookie path to "/" for tomcat, but this hasn't had any effects.

Does somebody know how to solve this?

I just wanted to use this setup during development. In production mode i'am aming at having the GWT code directly delivered by the tomcat app.

Thanks!


When the user logs in request something from your jetty server but include cookie string in the url. Set the cookie in the image response.

For example - on the login-success page, the one that sets cookie for tomcat, add an image link:

on jetty server map /img.gif to a filter that adds cookie "cookiestring" (and place there 1px x 1px blank image as well). Done, your simple single-sign-on is ready.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜