如何让 servlet 容器从查询字符串而不是 URL 中读取 JSESSIONID
我需要能够通过将 JSESSIONID 指定为 url 查询字符串的参数而不是 URL 本身的一部分来维护会话。
换句话说,我需要维护这样的会话
http://myserver.com?jsessionid=A463B23BC4F2342FA
http://myserver.com;jsessionid=A463B23BC4F2342FA
对于 servlet 容器,我同时使用 tomcat 6.0 和 weblogic 10.3
原因:
我正在创建一个 Google 地球网络链接,这需要我为客户端发出的请求保留一个会话。 Google 地球不支持 cookie,并且似乎无法更改它用于发出请求的 URL。我只能通过将以下内容添加到服务器响应中的 kml 来告诉它在后续请求中附加查询字符串参数
<NetworkLinkControl>
<cookie>JSESSIONID=A463B23BC4F2342FA</cookie>
</NetworkLinkControl>
I need to be able to maintain a session by having the JSESSIONID specified as a parameter of the query string of the url rather than part of the URL itself.
I other words I need to maintain a session like this
http://myserver.com?jsessionid=A463B23BC4F2342FA
rather than
http://myserver.com;jsessionid=A463B23BC4F2342FA
For a servlet container I'm using both tomcat 6.0 and weblogic 10.3
Reason:
I'm creating a Google Earth network link which requires me to keep a session for the requests a client makes. Google Earth doesn't support cookies and it appears there is no way to change the url that it uses to make requests. I can only tell it to append a query string parameter on subsequent requests by adding the following to the kml in my server responses
<NetworkLinkControl>
<cookie>JSESSIONID=A463B23BC4F2342FA</cookie>
</NetworkLinkControl>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不可能。我会在您这边创建一个 filter ,每当 URL 到达时,它会将请求重定向到正确的 URL <查询字符串中的 code>JSESSIONID。
基本启动示例:
将其映射到 URL 模式,该模式涵盖可能由该站点发起的请求。或者,如果没有,则仅在
/*
上。Not possible. I'd create on your side a filter which redirects the request to the proper URL whenever an URL arrives with the
JSESSIONID
in the query string.Basic kickoff example:
Map this on an URL pattern which covers requests which could potentially originate by that site. Or if there is none, just on
/*
.为此,我们创建了定制 Tomcat Valve。它非常简单,但是特定于 Tomcat。
We have created custom Tomcat Valve for this purpose. It's pretty straightforward, but Tomcat-specific.