You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David Molloy <mo...@eeng.dcu.ie> on 2000/11/13 17:17:31 UTC

session.getSessionContext();

Hi,

	I'm trying to write a simple Snoop servlet for my system
and have run into a small problem while porting from JServ to Tomcat.
I have sessions working for authentication etc. - however when I use

HttpSessionContext context = session.getSessionContext();
System.err.println("Context = " + context);
System.err.println("Enumeration = " + context.getIds());
System.err.println("NextElement = " + context.getIds().nextElement());	

The Enumeration doesn't give an error but it doesn't fill up, despite
the fact that there is definately a session open (you need to be
logged in to use the snoop servlet).  For some reason the context
doesn't seem to have any Ids, and hence the next line gives a
java.util.NoSuchElementException: VectorEnumerator

I've been looking for docs on any changes in session but didn't 
find any.  Any ideas would be greatly appreciated...thanks.

Dave Molloy


Re: session.getSessionContext();

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
David Molloy wrote:

> Hi,
>
>         I'm trying to write a simple Snoop servlet for my system
> and have run into a small problem while porting from JServ to Tomcat.
> I have sessions working for authentication etc. - however when I use
>
> HttpSessionContext context = session.getSessionContext();
> System.err.println("Context = " + context);
> System.err.println("Enumeration = " + context.getIds());
> System.err.println("NextElement = " + context.getIds().nextElement());
>
> The Enumeration doesn't give an error but it doesn't fill up, despite
> the fact that there is definately a session open (you need to be
> logged in to use the snoop servlet).  For some reason the context
> doesn't seem to have any Ids, and hence the next line gives a
> java.util.NoSuchElementException: VectorEnumerator
>
> I've been looking for docs on any changes in session but didn't
> find any.  Any ideas would be greatly appreciated...thanks.
>
> Dave Molloy

See the Servlet 2.2 specification at
<http://java.sun.com/products/servlet/download.html>, and the
corresponding servlet API Javadocs.  You will find that the
getSessionContext() method has been deprecated, and returns an "empty"
session context.  Likewise, the ServletContext.getServlet() method has
been deprecated, and always returns null.  These tend to be the two
largest issues when porting applications based on the servlet 2.0 API (as
Apache JServ is).

Craig McClanahan