¿Dónde se mantienen las sesiones en los servlets?

In Servlets we can use the feature of Session Tracking. So i want to just ask that the sessions are maintained onto the clientside or on serverside.

If it's on clientside then where?
Can i create session on the clientside HTTPSession?

I found one article which tells that sessions on clientside as well as serverside can be maintained.

preguntado el 01 de febrero de 12 a las 03:02

2 Respuestas

It is the server which will maintain the sessions. And it is the server responsibilty to allow session tracking happen. Clients need not bother about sending any information explicitly. As Client can sends Cookies saved on the client along with every request, server might use Cookies for sesssion tracking.

Nota: Cookies are just one of the way to implement Session Tracking. It is also the best way

So server uses Cookies as one of the ways to handle session tracking.

También se puede realizar de otras formas:

Reescritura de URL - la aplicación / servidor debe agregar la identificación de la sesión en todas las URL / enlaces. Cuando se invocan desde el cliente, la sesión llega al servidor junto con la URL.

Campos de formulario ocultos - Los formularios pueden contener un tipo de entrada oculto con la identificación de la sesión como valor de campo. Cuando se publica el formulario, la identificación de la sesión viene junto con los datos del formulario.

Respondido 01 Feb 12, 09:02

Thanks..so if we delete the cookies from client side then the session gets destroy which is maintained on the server side.Am I Right?? - user460920

Yes, it will get destroyed after some timeout value. Because, the cookie are deleted on client side, the client will no more be able to send cookies to server, so, the session created on server is no more accessible. - Ramesh PVK

Session resides on server side on client side we have cookie (or jsessionId or hidden form fields) to map the request with server's session

How it maps

When you submit a request for the first time( from the beginning of the time), server gives you a cookie with response they send your browser accepts that cookie it contains the expiry date, content (some String), and domain name now when you send the request again to server your browser will add that cookie for that domain in header so when server receives the request it sees the cookie from header and maps that content with sessionId on server

Para su información

You can also have session in other applications (for example peer-peer app)

Respondido 01 Feb 12, 08:02

ok thanks..can you pls explain in brief that is it thru the cookies from client side the sessions on the server side are found..?? - user460920

sorry not got your point...You can also have session in other applications (for example peer-peer app)?? - user460920

you can also have session in your chat application you create (TCP/ IP chat app desktop) - Jmj

thanks for your answer..one query is still there.. can we create sessions on the client side if we want?I got that the sessionid is on the server side which takes info from cookie.So serverside sessions are maintained but can we create sessions on the clientside too(not cookie,URL rewriting or hidden fields) - user460920

logically it doesn't make sense for web app - Jmj

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.