This is a user error.
It is not valid to reference pageContext outside the actual execution of
the tag. Once doEndTag() is called, none of the instance variables have
any valid values.
Craig McClanahan
On Wed, 15 Aug 2001, YMikulski wrote:
> Hello!
> I found a mistake in implementation jsp standart.
> Please, look at this code and comments in it.
> ------------------------------------------------------
> package test;
>
> import javax.servlet.*;
> import javax.servlet.http.*;
> import javax.servlet.jsp.*;
> import javax.servlet.jsp.tagext.*;
>
> public class TestTag extends TagSupport implements
> HttpSessionBindingListener, java.io.Serializable {
>
> public final int doEndTag() throws JspException {
> pageContext.getSession().setAttribute("stat.notify", this);
> }
>
> public void valueUnbound(HttpSessionBindingEvent event) {
> // MISTAKE!!!
> // When session expires or we execute session.invalidate(),
> // valueUnbound method is called and pageContext.getServletContext()
> // returns null!!! (in this example: context is null).
> ServletContext context = pageContext.getServletContext();
> }
> }
> --------------------------------------------------------------------
> Regards, Yauheni Mikulski
>
>
>
>