Re: PageContext is always null with taglibs

2002-09-12 Thread Jungho Kim

try overriding setPageContext(PageContext ctx) and check that it is being
invoked.

public void setPageContext(PageContext ctx) {
System.out.println("Inside " + getClass().getName() +
".setPageContext()...");
super.setPageContext(ctx);
}

That should settle any doubt that pageContext is being set.


- Original Message -
From: "Byrne Reese" <[EMAIL PROTECTED]>
To: "Tag Libraries Users List" <[EMAIL PROTECTED]>
Sent: Thursday, September 12, 2002 7:59 PM
Subject: RE: PageContext is always null with taglibs


> On Thu, 2002-09-12 at 16:45, Martin Cooper wrote:
> > 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
>
> So I actually only enclosed a code snippet... I did several variations
> while unit testing - and even tried to implement a simple HelloWorld
> TagSupport class... but with no luck. :(
>
> I just seems odd since at one point it was working... but that was a
> while ago, and I am kicking myself because I am not sure what on my
> system changed other than Tomcat... well I did upgrade Axis Beta 3 to
> RC1, but I can't see how that could possibly impact the JSP layer in
> anyway.
>
> I also tried reverting to an older servlet.jar class - but still, no
> luck. Perhaps there is some configuration parameter in Tomcat I am
> missing? Jeeesh, who knows?
>
> > > -Original Message-
> > > From: Byrne Reese [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, September 12, 2002 4:00 AM
> > > To: [EMAIL PROTECTED]
> > > 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:
> > > --
> > > ---
> > >
> > >  > > cityId="/world/south_america/bolivia/cobija_city"/>
> > >
> > > City Name: 
> > >
> > >
> > > 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:[EMAIL PROTECTED]>
> > > For additional commands, e-mail:
> > > <mailto:[EMAIL PROTECTED]>
> > >
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
> >
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: PageContext is always null with taglibs

2002-09-12 Thread Craig Longman

On Thu, 2002-09-12 at 19:59, Byrne Reese wrote:
> I just seems odd since at one point it was working... but that was a
> while ago, and I am kicking myself because I am not sure what on my
> system changed other than Tomcat... well I did upgrade Axis Beta 3 to
> RC1, but I can't see how that could possibly impact the JSP layer in
> anyway.

it also seems that there is various problems for some people with the
new jasper2 (the page compiler) in tomcat 4.1 related to the new tag
caching it does.  the solution posted to tomcat-users is to disable that
feature:

 
  jsp
  org.apache.jasper.servlet.JspServlet
  
   logVerbosityLevel
   DEBUG
  
  
   enablePooling
   false
  
  3
 

maybe this is the root of your problem?

-- 

CraigL->Thx();
Be Developer ID: 5852




signature.asc
Description: This is a digitally signed message part


RE: PageContext is always null with taglibs

2002-09-12 Thread Craig Longman

On Thu, 2002-09-12 at 19:59, Byrne Reese wrote:
> So I actually only enclosed a code snippet... I did several variations
> while unit testing - and even tried to implement a simple HelloWorld
> TagSupport class... but with no luck. :(

one other thing that might cause this, is if you override the existing
setPageContext() method, and forget to call super.setPageContext() from
there, then the protected pageContext member won't be set.  sounds like
you did a simple servlet though and are still seeing this.

if you haven't done this yet, try _overriding_ the setPageContext() and
see if/when you're called.  you can do this by:

public void setPageContext( PageContext pageContext )
{
  super.setPageContext( pageContext );

  pageContext.getServletContext().log( "pageContext: " + pageContest );
}

i don't think that anything configuration wise could have changed this,
but at least then you'd know wether or not setPageContext() was being
called which might help...

cheers,

-- 

CraigL->Thx();
Be Developer ID: 5852




signature.asc
Description: This is a digitally signed message part


RE: PageContext is always null with taglibs

2002-09-12 Thread Martin Cooper

If you think it might be a Tomcat configuration problem, then why not try
dropping in something that's known to work, and see if it works for you? You
could try the JSTL examples, or the struts-example.war web app from Struts
1.1-b2.

--
Martin Cooper


> -Original Message-
> From: Byrne Reese [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 12, 2002 5:00 PM
> To: Tag Libraries Users List
> Subject: RE: PageContext is always null with taglibs
> 
> 
> On Thu, 2002-09-12 at 16:45, Martin Cooper wrote:
> > 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
> 
> So I actually only enclosed a code snippet... I did several variations
> while unit testing - and even tried to implement a simple HelloWorld
> TagSupport class... but with no luck. :(
> 
> I just seems odd since at one point it was working... but that was a
> while ago, and I am kicking myself because I am not sure what on my
> system changed other than Tomcat... well I did upgrade Axis Beta 3 to
> RC1, but I can't see how that could possibly impact the JSP layer in
> anyway.
> 
> I also tried reverting to an older servlet.jar class - but still, no
> luck. Perhaps there is some configuration parameter in Tomcat I am
> missing? Jeeesh, who knows?
> 
> > > -Original Message-
> > > From: Byrne Reese [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, September 12, 2002 4:00 AM
> > > To: [EMAIL PROTECTED]
> > > 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:
> > > --
> > > ---
> > > 
> > >  > > cityId="/world/south_america/bolivia/cobija_city"/>
> > > 
> > > City Name: 
> > > 
> > > 
> > > 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:[EMAIL PROTECTED]>
> > > For additional commands, e-mail: 
> > > <mailto:[EMAIL PROTECTED]>
> > > 
> > > 
> > 
> > 
> > --
> > To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> > 
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> 
> 


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: PageContext is always null with taglibs

2002-09-12 Thread Byrne Reese

On Thu, 2002-09-12 at 16:45, Martin Cooper wrote:
> 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

So I actually only enclosed a code snippet... I did several variations
while unit testing - and even tried to implement a simple HelloWorld
TagSupport class... but with no luck. :(

I just seems odd since at one point it was working... but that was a
while ago, and I am kicking myself because I am not sure what on my
system changed other than Tomcat... well I did upgrade Axis Beta 3 to
RC1, but I can't see how that could possibly impact the JSP layer in
anyway.

I also tried reverting to an older servlet.jar class - but still, no
luck. Perhaps there is some configuration parameter in Tomcat I am
missing? Jeeesh, who knows?

> > -Original Message-
> > From: Byrne Reese [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, September 12, 2002 4:00 AM
> > To: [EMAIL PROTECTED]
> > 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:
> > --
> > ---
> > 
> >  > cityId="/world/south_america/bolivia/cobija_city"/>
> > 
> > City Name: 
> > 
> > 
> > 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:   
> > 
> > For additional commands, e-mail: 
> > 
> > 
> > 
> 
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 
> 


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: PageContext is always null with taglibs

2002-09-12 Thread Martin Cooper

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:[EMAIL PROTECTED]]
> Sent: Thursday, September 12, 2002 4:00 AM
> To: [EMAIL PROTECTED]
> 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:
> --
> ---
> 
>  cityId="/world/south_america/bolivia/cobija_city"/>
> 
> City Name: 
> 
> 
> 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:   
> 
> For additional commands, e-mail: 
> 
> 
> 


--
To unsubscribe, e-mail:   
For additional commands, e-mail: