简体   繁体   English

jsessionid被忽略

[英]jsessionid ignored

I'm using a URL with a jsessionid, eg. 我正在使用带有jsessionid的URL,例如。

http://localhost:8080/myservlet;jsessionid=123 HTTP://本地主机:8080 / myservlet; JSESSIONID = 123

Yet whenever I read the session ID in the HttpServletRequest the value is never 123, but instead a generated session ID, eg. 但是,每当我在HttpServletRequest中读取会话ID时,该值就永远不会为123,而是生成的会话ID,例如。 B663A96D3FBC84B4A427C0810EAB9073. B663A96D3FBC84B4A427C0810EAB9073。

Why is my jsessionid being ignored? 为什么我的jsessionid被忽略?

That's because you specified a session ID for which no concrete HttpSession object exist in server's memory. 那是因为您指定了一个会话ID,服务器内存中没有针对该会话ID的具体HttpSession对象。 In other words, the given session ID is unknown/invalid. 换句话说,给定的会话ID是未知/无效。 You need to specify a session ID which refers a valid and existing HttpSession object in server's memory. 您需要指定一个会话ID,该ID引用服务器内存中的有效HttpSession对象。

Assuming that you do have a valid HttpSession with ID B663A96D3FBC84B4A427C0810EAB9073 currently in server's memory, then the following link will work and give the enduser access to exactly that HttpSession : 假设服务器内存中当前确实有一个ID为B663A96D3FBC84B4A427C0810EAB9073的有效HttpSession ,那么以下链接将起作用,并赋予最终用户访问该HttpSession权限:

http://localhost:8080/myservlet;jsessionid=B663A96D3FBC84B4A427C0810EAB9073 HTTP://本地主机:8080 / myservlet; JSESSIONID = B663A96D3FBC84B4A427C0810EAB9073

My guess would be that most application servers these days default to using cookies for session tracking, not URL rewriting. 我的猜测是,如今大多数应用程序服务器默认都使用cookie进行会话跟踪,而不是URL重写。 So if your request contains both a session cookie and a JSESSIONID in the URL, it will probably use the one from the cookie. 因此,如果您的请求在URL中同时包含会话cookie和JSESSIONID,则可能会使用cookie中的一个。 Check the documentation of your appserver for how to configure this. 检查您的appserver文档以了解如何配置。

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

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