You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "O'Toole, Joe" <Jo...@fmr.com> on 2006/12/12 19:17:00 UTC

Preprocessing of request

Hi

My application receieves an xml request. I need to perform some
transformation of this xml before performing business logic etc.

Is there anyway I can configure through struts that I can invoke a java
class that does this task as I don't want to perform it in the action or the
model. Something like the plug-in element in the struts-config.xml that
invokes a java class that adheres to correct interface for performing tasks
when the app is starting/stopping.

I cannot see where I can do this and I would really to make this task
configurable and push it out from the action or model

Thanks

Joe



Re: Preprocessing of request

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Your best bet most likely is a servlet filter.  Do the transformation and
stuff the transformed content in request as an attribute, then grab it
later in your Actions.

Which version of Struts are you using?  If pre-1.3, modifying the RP is
one of the few other options as Dave mentioned... you might also be able
to have a base Action that all your Actions extend from, and the base
action does the transformation before the real work happens.  This might
work if you don't need the transformation to happen before that point.

If using 1.3.x, you could write a command to do it and modify the RP chain.

If 2.x, an interceptor is probably the right answer.

However, in all these cases, a servlet filter would work, and would keep
your transformation logic abstracted out of Struts itself, so one less
thing to worry about if you upgrade versions later :)

Frank


-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

On Tue, December 12, 2006 1:17 pm, O'Toole, Joe wrote:
> Hi
>
> My application receieves an xml request. I need to perform some
> transformation of this xml before performing business logic etc.
>
> Is there anyway I can configure through struts that I can invoke a java
> class that does this task as I don't want to perform it in the action or
> the
> model. Something like the plug-in element in the struts-config.xml that
> invokes a java class that adheres to correct interface for performing
> tasks
> when the app is starting/stopping.
>
> I cannot see where I can do this and I would really to make this task
> configurable and push it out from the action or model
>
> Thanks
>
> Joe
>
>
>


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