You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ksitron <ks...@elp.rr.com> on 2004/06/06 01:39:02 UTC
clearing an ActionForm from session
I have an action form whose data is needed across several JSP's, for
this reason I set the scope to session for this ActionForm in my
struts-config.xml.
When the transaction is completed I want the form to go away. What is
the best practice for this.
Thanks in advance.
--
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: clearing an ActionForm from session
Posted by ksitron <ks...@elp.rr.com>.
Thanks Riyad. The problem with having the form hang around is. There
could potentially be a very large number of
sessions (users) , all with a form to hang on to. So, the memory
consumption could end up causing problems.
Riyad Kalla wrote:
> You can forcibly remove it as the last step in your last action before
> sending the user to a success page:
> request.getSession().setAttribute("formName", null);
>
> where "formName" is the same name you gave the bean in your
> struts-config.xml file in the "form-beans" section of the file. There
> is no automatic way I know of that you can tell Struts to destroy an
> object on purpose.
>
> If you just want to reset the form, and not null it out, make your
> last line instead of the setAttribute, make it:
> form.reset();
>
> this way the form is still cached for use, but values are empty.
>
> ksitron wrote:
>
>>
>> I have an action form whose data is needed across several JSP's, for
>> this reason I set the scope to session for this ActionForm in my
>> struts-config.xml.
>> When the transaction is completed I want the form to go away. What
>> is the best practice for this.
>>
>> Thanks in advance.
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Kevin J Citron
Sr. Object Imagineer
Optimized Objects, Inc.
EL Paso, Texas 79930
(915) 565-7785/566-2403
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: clearing an ActionForm from session
Posted by Riyad Kalla <rs...@email.arizona.edu>.
You can forcibly remove it as the last step in your last action before
sending the user to a success page:
request.getSession().setAttribute("formName", null);
where "formName" is the same name you gave the bean in your
struts-config.xml file in the "form-beans" section of the file. There is
no automatic way I know of that you can tell Struts to destroy an object
on purpose.
If you just want to reset the form, and not null it out, make your last
line instead of the setAttribute, make it:
form.reset();
this way the form is still cached for use, but values are empty.
ksitron wrote:
>
> I have an action form whose data is needed across several JSP's, for
> this reason I set the scope to session for this ActionForm in my
> struts-config.xml.
> When the transaction is completed I want the form to go away. What is
> the best practice for this.
>
> Thanks in advance.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org