简体   繁体   English

如何在jboss 7的URL中使用会话ID?

[英]How to use session id in url with jboss 7?

I using Openjdk 7 and JBoss 7. 我使用的是Openjdk 7和JBoss 7。

I can use sessions with cookies good. 我可以使用带有cookie的会话。 Some of clients have not ability to use cookie so i need to pass session id to server via URL. 一些客户端无法使用Cookie,因此我需要通过URL将会话ID传递给服务器。 When i try to do so, session can't be initialized (i turned off cookies to test). 当我尝试这样做时,无法初始化会话(我关闭了cookie进行测试)。 I used different variables in url to pass session id like: sessionID, jsessionid, sid, but no one helped to initialize session by provided id. 我在url中使用了不同的变量来传递会话ID,例如:sessionID,jsessionid,sid,但是没有人通过提供的ID来帮助初始化会话。

So the question is what variable should contain session id in url when client can't use cookies, and how to setup jboss server to accept session id from url? 因此,问题是当客户端无法使用cookie时,哪个变量应在url中包含会话ID,以及如何设置jboss服务器以接受来自url的会话ID?

You should not modify the URLs directly. 您不应该直接修改URL。 The trick to make that work is to ALWAYS use the response.encodeURL() or response.encodeRedirectURL() methods when generating URLs. 使之起作用的技巧是在生成URL时始终使用response.encodeURL()或response.encodeRedirectURL()方法。 See the javadoc here . 此处查看javadoc。

The JSTL <c:url> tag uses this method internally to generate URLs. JSTL <c:url>标记在内部使用此方法来生成URL。 So it's safe to use it. 因此,使用它是安全的。

These methods will append the session ID to the URL if needed. 如果需要,这些方法会将会话ID附加到URL。 Note that to make them work, cookies must be disabled when the session is first created. 请注意,为了使它们起作用,首次创建会话时必须禁用cookie。 If you create the session while cookies are enabled, and then disable cookies, it won't work. 如果在启用Cookie的情况下创建会话,然后禁用cookie,则它将无法正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM