You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "White, Joshua A (CASD, IT)" <Jo...@thehartford.com> on 2003/03/13 19:44:23 UTC

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 







----------------------------------------------------------------------------
-------------
Date: Sun, 09 Jun 2002 16:04:17 -0400
From: Ted Husted <hu...@apache.org>
Subject: getServlet()?
Content-Type: text/plain; charset=us-ascii

The ActionServletWrapper class was provided as a security patch. As
such, it takes the stances that we should start by shutting everything
down, and then open things up as needed. 

Off-hand, wanting to access servlet initialization parameters in
validate() sounds like a reasonable use-case. If you want to post a
patch to bugzilla, I'll see if we can do something about a 1.0.3
release.

-- Ted Husted, Husted dot Com, Fairport NY US
-- Developing Java Web Applications with Struts
-- Tel: +1 585 737-3463
-- Web: http://husted.com/about/services


Geoffrey Corb wrote:
> 
> I have been attempting to update a project from Struts 1.0 to 1.0.2 to
> resolve some file upload problems.  Now, I've found that the ActionForm's
> getServlet() method no longer exposes the ActionServlet.  This is
especially
> problematic to me, since a fair number of our ActionForm-derived classes
use
> the ActionServlet to get at the ServletContext in their validation
scripts.
> Is there a workaround possible?  I'm trying to retrieve initialization
> parameters from the ServletContext in the validate() methods of my
> ActionForm-derived classes.
> 
> Another question:  What good is the ActionServletWrapper when it *barely*
> wraps the ActionServlet class?  I understand wanting to "prevent public
> String properties of ActionServlet from being changed via a query string"
> (quoted from release notes), but why not provide access to other,
relatively
> important, methods, like getServletContext()?
> 
> - G. Corb
> ____________________________________________________________
> This communication, including attachments, is for the exclusive use of
> addressee and may contain proprietary, confidential  or privileged
> information. If you are not the intended recipient, any use, copying,
> disclosure, dissemination or distribution is strictly prohibited. When
> addressed to our clients any opinions or advice contained in this email
are
> subject to the terms and conditions expressed in the governing Synergenic
> client Agreement.

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


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

Posted by "Craig R. McClanahan" <cr...@apache.org>.

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