You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Albrecht Berger <be...@gmx.ch> on 2004/03/20 13:47:32 UTC

ValidatorForm.getServlet() == null !!

Hello,

I need the ServletContext in one of my forms, which
I'm trying to get with :
getServlet().getServletContext()

Unfortunately I get a NullpointerException,
because the servlet is null.

How could this be, is there a workaround ?

Thx
berger



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: ValidatorForm.getServlet() == null !!

Posted by Curtis Taylor <c....@verizon.net>.
Hi Albrecht,

The ActionServlet in an ActionForm is a private member with no accessor methods. 
So, try this in your form:

this.servlet.getServletContext();

HTH,

Curtis

Albrecht Berger wrote:
> Hello,
> 
> I need the ServletContext in one of my forms, which
> I'm trying to get with :
> getServlet().getServletContext()
> 
> Unfortunately I get a NullpointerException,
> because the servlet is null.
> 
> How could this be, is there a workaround ?
> 
> Thx
> berger


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org