It's not possible. A session combines a series of requests from a certain source into a single unit. But when the servlet's init() method is running, there have not been any requests yet. So the concept of session does not apply there.
Session is taken from the request, and request is not processed until init() has executed completely.
Session is generally managed using Cookies or URL rewritting. Both of these are a part of request (Cookies come as header and URL encoding is part of URI) and request is processed by service() method of servlet.
If the session is created(although it is NOT possible) in init(), there will be only one session for all the requests processed by that servlet becase in most (if not all) web applications, there is only instance of servlet, which serves all the clients. This means the init() is executed only once, which in turn would mean that there will be ONLY one session. In nutshell, session can no longer have any meaning as session's main objective is to identify clients. If ALL are treated as ONE, we won't need sessions.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: how to get a session object in the init() method of a servlet?