I want to get Java HttpSession
by JSESSIONID. Is it possible? If yes, how?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
You need to collect them all in a
Map
using aHttpSessionListener
yourself.Just register it in
web.xml
as follows to run it:Then, anywhere you want just do
HttpSessionCollector.find(sessionId)
to get theHttpSession
in question.That said, this is a huge smell. There are certainly better ways to solve the actual functional requirement than this ;) As I commented in your follow-up question:
Take it serious. We're not teasing you, we're just trying to help you in the right direction to avoid that your project/webapp will break due to security holes and bad practices and/or that you will get fired.
You can do it as above but the existence of such a facility is a prima facie security breach between different users. You shouldn't be building things like this into your application.
No, the API does not permit this.
I'd say more, but that's about all there is to it.