tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Cooper" <martin.coo...@tumbleweed.com>
Subject RE: PageContext is always null with taglibs
Date Thu, 12 Sep 2002 23:45:52 GMT
Are you absolutely certain that pageContext is null, and that the problem is
not caused by either 'getId()' or 'city' being null? You're not checking
those before passing them to pageContext.

Custom tags work just fine in Tomcat 4.0.4, so I think the problem must be
somewhere in your own tag code.

--
Martin Cooper


> -----Original Message-----
> From: Byrne Reese [mailto:byrne@majordojo.com]
> Sent: Thursday, September 12, 2002 4:00 AM
> To: taglibs-user@jakarta.apache.org
> Subject: PageContext is always null with taglibs
> 
> 
> I am trying to write a custom taglib that extends the 
> TagSupport class. 
> 
> At one point my implementation worked, but when upgrading to Tomcat
> 4.0.4, I keep getting a NullPointerException because the protected
> variable pageContext is null.
> 
> Any clues? Is tomcat's servlet implementation no longer setting the
> PageContext? What gives? Or how do I get a handle to the 
> request and/or
> response context so that I can get and put attributes and write output
> to the browser?
> 
> Here is my code BTW:
> 
> JSP:
> --------------------------------------------------------------
> -----------
> 
> <otg:getCity id="city"
> cityId="/world/south_america/bolivia/cobija_city"/>
> 
> <p>City Name: <jsp:getProperty name="city" property="name"/></p>
> 
> 
> CLASS:
> --------------------------------------------------------------
> -----------
> public class GetCityTag extends TagSupport {
>         
>     /* blah blah blah */
>     
>     public int doEndTag() 
>         throws JspException 
>     {
>         City city = (City)getCity(getCityId());
>         /* this next line is where the NullPointerException occurs */
>         pageContext.setAttribute(getId(), city);
>         /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */
>         try {
>             pageContext.getOut().write("City id is " + cityId + "!");
>             pageContext.getOut().write("Storing fetched city
> '"+city.getName()+
>                               "' as " + id + "!");
>         } catch(IOException e) {
>             throw new JspTagException("An IOException occurred.");
>         }
>         return EVAL_PAGE;
>     }
>     
> }
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: 
> <mailto:taglibs-user-help@jakarta.apache.org>
> 
> 


--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message