Rasmikanta Guru
Rasmikanta Guru

Reputation: 51

How can i create a session object using session id?

I want to know, how can i create a session object using session id in java.

Because when we are passing session id by appending in the URL, how the server is creating the session object using that session id.

Is their any way?

Upvotes: 0

Views: 1450

Answers (3)

AmitG
AmitG

Reputation: 10543

When you invoke request.getSession() again (I said again )in your code then container will automatically make that session available for you. We need not to worry about it. Anyways if you want to know about how it is handled/created/(returning reference of same session object) then use decompiler and see the code for how session object is created on the basis of jsessionID.

Upvotes: 0

sanit
sanit

Reputation: 1764

As Sudhakar has replied there is no way to create a session using an ID. And why actually you need to do this. If you think properly then you will not need to create session using an id. There must be another solution for your requirememt. Share your exact requirement so that we might help you.

Upvotes: 0

Sudhakar
Sudhakar

Reputation: 4873

You cannot construct session from Session Id , it actually servers responsibility to create session and manage it.Session Id is just a unique id that server passes it browser to uniquely identify an HttpSession and maintain a conversational State , but in reality HTTP is not Stateless

Check the below link this explains it rather succinctly

How session works

I strongly advice to read Head First Servlets and JSP

Upvotes: 1

Related Questions