You should google for
JSP Session Management to learn a lot of details but basically:
1) When a session is created, the next response to the client sends a Cookie with a unique ID for the session for that client
2) When the client sends each new request from then on, it includes the same Cookie with the session ID for its intended Session
3) Part of the pre-processing of the request done by the server is to find that Cookie with ID and associate the proper Session with the request.
So what do you have to do? Really nothing except call request.getSession() or use the scope=session attribute in tags as appropriate.
But like I said, google for session management to learn more - and what to do to prevent clients that have Cookies turned off from breaking.