I'm using a URL with a jsessionid, eg.
http://local开发者_如何学运维host: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. B663A96D3FBC84B4A427C0810EAB9073.
Why is my jsessionid being ignored?
That's because you specified a session ID for which no concrete HttpSession
object exist in server's memory. In other words, the given session ID is unknown/invalid. You need to specify a session ID which refers a valid and existing HttpSession
object in server's memory.
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
:
http://localhost:8080/myservlet;jsessionid=B663A96D3FBC84B4A427C0810EAB9073
My guess would be that most application servers these days default to using cookies for session tracking, not URL rewriting. So if your request contains both a session cookie and a JSESSIONID in the URL, it will probably use the one from the cookie. Check the documentation of your appserver for how to configure this.
精彩评论