tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <Craig.McClana...@eng.sun.com>
Subject Re: sessions and JSP Tag Handlers
Date Mon, 10 Jul 2000 23:05:58 GMT
Joel Regen wrote:

> "Craig R. McClanahan" wrote:
>
> > Joel Regen wrote:
> >
> > >
> > > What if, in a tag handler, I had code like:
> > >
> > >     pageContext.getSession().setAttribute( "foo", bar, PageContext.SESSION_SCOPE);
> > >
> > > and in another tag handler, referenced on another page I had:
> > >
> > >     pageContext.getSession().getAttribute( "foo", PageContext.SESSION_SCOPE);
> > >
> > > Would that be sufficient to create and access an object with session scope
entirely within
> > > the tag handler semantics?
> > >
> >
> > Actually, you should leave the getSession() thing out of these calls:
> >
> >     pageContext.setAttribute("foo", bar, PageContext.SESSION_SCOPE);
> >     bar = pageContext.getAttribute("foo", PageContext.SESSION_SCOPE);
> >
> > This is preferable to using the session object directly, because it assures synchronization
> > between the page context (for your tags) and the actual session attributes.
> >
>
> this is not working between pages. any ideas on why?

It has worked for me in the past.  Are you sure you are really in the
same session in both pages
(and the same web application)?

One thing to note is that Tomcat 3.1 has a bug if you are using
sendRedirect() -- it loses cookies
and headers (including the session ID header).  Be sure you are using a
recent build of Tomcat 3.2
beta if you want this to work across sendRedirect() calls.

Craig

Mime
View raw message