You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "Craig R. McClanahan" <cr...@apache.org> on 2003/03/13 21:24:55 UTC

Re: ActionForm's "getServlet" method and "servlet" attribute return n ull


On Thu, 13 Mar 2003, White, Joshua A (CASD, IT) wrote:

> Date: Thu, 13 Mar 2003 13:44:23 -0500
> From: "White, Joshua A (CASD, IT)" <Jo...@thehartford.com>
> Reply-To: Struts Developers List <st...@jakarta.apache.org>
> To: 'Struts Developers List' <st...@jakarta.apache.org>
> Subject: ActionForm's "getServlet" method and "servlet" attribute return
>     n ull
>
> All,
>
> I am having problems with the ActionForm's "getServlet" method and "servlet"
> attribute.  I have created a class called "BaseForm" which simply extends
> ActionForm.  When I attempt to get a reference to the ActionServlet using
> the "getServlet" method or "servlet" attribute, I receive a null pointer
> exception.  I found a post on a similar problem (below).  Is this behavior
> still a bug?  I am also trying to get a reference to the ServeltContext.
>
> Regards,
>
> Joshua
>

If you are creating the form bean instance youself:

  MyFormBean mfb = new MyFormBean();

then it is your responsibility to call mfb.setServlet() in order to set
the "servlet" property.  Struts does this for you when it automatically
creates form bean instances.

You might also want to investigate whether using
RequestUtils.createActionForm() can help you.

Craig

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