Hi Everybody, I am learning sessions in servlet. I am using "Resin" webserver. To understand the session context object I am executing folloing code. ==== Code==== res.setContentType("text/plain"); PrintWriter out = res.getWriter(); // Get the current session object, create one if necessary HttpSession dummySession = req.getSession(true); // Use the session to get the session context HttpSessionContext context=dummySession.getSessionContext(); Enumeration ids = context.getIds(); ==== Code ends=== I am getting null pointer exception on the last statement(i.e. Enumeration ids = context.getIds() . So I came to know that getSessionContext function is not returing a session context object. What I am doing wrong? I will appreciate anybody's help in this regard. Thanks, Srikanth.
Thank you so very much. I have one follow-up question. So sessions management can be done only by cookies and hidden fields? Is there any alternate for session context object? I read some where that whole session concept is depricated from the servlet. Is that true. Once again thank you very much. Regards, Srikanth.
Author and all-around good cowpoke
Joined: Mar 22, 2000
Cookies, Hidden Fields and URL Rewriting are the only ways I know of to associate a particular user with a session. HttpSession is still very much a part of the API - it is essential to just about everything. You really should download the servlet and JSP API documents from java.sun.com - Bill