You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Frank W. Zammetti" <fz...@omnytex.com> on 2006/11/16 19:33:47 UTC
RE: A Filter Action !
If your using S2, interceptors would be the way to go. I assume your
using S1 though...
If your using 1.3.x, you can create a Command and have it fire in the
chain before your Action.
If your using < 1.3.x, either (a) extend RequestProcessor and put your
filter code in there, or (b) subclass Action and have the fiter code in
the subclass, then extend all your Actions from that. It would go
something like execute() in CustomAction (which extends from Action) does
your check and forwards to a JSP of your choice if applicable, and if not,
then it calls realExecute(), which would be a method defined in an Action
extended from CustomAction, and has the same signature as execute().
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 Thu, November 16, 2006 12:48 pm, Youssef A. Mohammed wrote:
> Thank you for your reply ... but I don't want to do this in a servlet
> filter, I just want some action filter to work similar to a servlet filter
> and make use of struts framework.
> Regards,
>
>
>> -----Original Message-----
>> From: Mahmoud Saeed(RSW) [mailto:Mahmoud_Saeed@rayacorp.com]
>> Sent: Thursday, November 16, 2006 8:46 PM
>> To: Struts Users Mailing List
>> Subject: RE: A Filter Action !
>>
>> Create a class that implements the Filter Interface and check in the
>> doFilter method on the attribute , is it exist [user logged-in before]
>> just call the doFilter(
) of the FilterChain object otherwise [user not
>> logged-in before] make a request dispatcher to the login page or what
>> ever.
>>
>> But, remember to apply the filter to all Actions by adding the following
>> tag in you web description:
>>
>>
>>
>> <filter>
>> <filter-name>SecurityFilter</filter-name>
>> <display-name>SecurityFilter</display-name>
>> <filter-class> ....... </filter-class>
>> </filter>
>> <filter-mapping>
>> <filter-name>SecurityFilter</filter-name>
>> <url-pattern>*.do</url-pattern>
>> </filter-mapping>
>> <filter-mapping>
>> <filter-name>SecurityFilter</filter-name>
>> <url-pattern>*.jsp</url-pattern>
>> </filter-mapping>
>>
>>
>>
>> ________________________________
>>
>> From: Youssef A. Mohammed [mailto:yali@ejada.com]
>> Sent: 16 äæÝãÈÑ, 2006 07:24 ã
>> To: 'Struts Users Mailing List'
>> Subject: A Filter Action !
>>
>>
>>
>> Folks;
>>
>> I want to set of action classes that should operate only
>> when
>> user object in the session. How can I add some filter action to forward
>> to some page (action forward) and bypass the main action classes.
>>
>> Regards,
>>
>>
>>
>>
>>
>> Youssef A. Mohammed Ali
>>
>> Senior System Analyst
>>
>>
>>
>> <http://www.ejada.com.sa/>
>>
>> Tel.: + (966 1) 472 2277 Ext. 226
>>
>> Fax: + (966 1) 472 4772
>>
>> P. O. Box: 55471 Riyadh, 11534, KSA
>>
>>
>>
>>
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: A Filter Action !
Posted by "Youssef A. Mohammed" <ya...@ejada.com>.
Thank you so much for you reply.
I am actually using 1.3.x and I thought about your (b) solution yet this
will required some manual effort (copy and paste the excecute code into the
realExcecute ones!)
I highly appreciate if you shed some light on creating a Command and having
it fired in the chain before the action.
Regards,
Youssef A. Mohammed Ali
Senior System Analyst
Tel.: + (966 1) 472 2277 Ext. 226
Fax: + (966 1) 472 4772
P. O. Box: 55471 Riyadh, 11534, KSA
> -----Original Message-----
> From: Frank W. Zammetti [mailto:fzlists@omnytex.com]
> Sent: Thursday, November 16, 2006 9:34 PM
> To: Struts Users Mailing List
> Cc: 'Struts Users Mailing List'
> Subject: RE: A Filter Action !
>
> If your using S2, interceptors would be the way to go. I assume your
> using S1 though...
>
> If your using 1.3.x, you can create a Command and have it fire in the
> chain before your Action.
>
> If your using < 1.3.x, either (a) extend RequestProcessor and put your
> filter code in there, or (b) subclass Action and have the fiter code in
> the subclass, then extend all your Actions from that. It would go
> something like execute() in CustomAction (which extends from Action) does
> your check and forwards to a JSP of your choice if applicable, and if not,
> then it calls realExecute(), which would be a method defined in an Action
> extended from CustomAction, and has the same signature as execute().
>
> 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 Thu, November 16, 2006 12:48 pm, Youssef A. Mohammed wrote:
> > Thank you for your reply ... but I don't want to do this in a servlet
> > filter, I just want some action filter to work similar to a servlet
> filter
> > and make use of struts framework.
> > Regards,
> >
> >
> >> -----Original Message-----
> >> From: Mahmoud Saeed(RSW) [mailto:Mahmoud_Saeed@rayacorp.com]
> >> Sent: Thursday, November 16, 2006 8:46 PM
> >> To: Struts Users Mailing List
> >> Subject: RE: A Filter Action !
> >>
> >> Create a class that implements the Filter Interface and check in the
> >> doFilter method on the attribute , is it exist [user logged-in before]
> >> just call the doFilter(
) of the FilterChain object otherwise [user not
> >> logged-in before] make a request dispatcher to the login page or what
> >> ever.
> >>
> >> But, remember to apply the filter to all Actions by adding the
> following
> >> tag in you web description:
> >>
> >>
> >>
> >> <filter>
> >> <filter-name>SecurityFilter</filter-name>
> >> <display-name>SecurityFilter</display-name>
> >> <filter-class> ....... </filter-class>
> >> </filter>
> >> <filter-mapping>
> >> <filter-name>SecurityFilter</filter-name>
> >> <url-pattern>*.do</url-pattern>
> >> </filter-mapping>
> >> <filter-mapping>
> >> <filter-name>SecurityFilter</filter-name>
> >> <url-pattern>*.jsp</url-pattern>
> >> </filter-mapping>
> >>
> >>
> >>
> >> ________________________________
> >>
> >> From: Youssef A. Mohammed [mailto:yali@ejada.com]
> >> Sent: 16 äæÝãÈÑ, 2006 07:24 ã
> >> To: 'Struts Users Mailing List'
> >> Subject: A Filter Action !
> >>
> >>
> >>
> >> Folks;
> >>
> >> I want to set of action classes that should operate only
> >> when
> >> user object in the session. How can I add some filter action to
> forward
> >> to some page (action forward) and bypass the main action classes.
> >>
> >> Regards,
> >>
> >>
> >>
> >>
> >>
> >> Youssef A. Mohammed Ali
> >>
> >> Senior System Analyst
> >>
> >>
> >>
> >> <http://www.ejada.com.sa/>
> >>
> >> Tel.: + (966 1) 472 2277 Ext. 226
> >>
> >> Fax: + (966 1) 472 4772
> >>
> >> P. O. Box: 55471 Riyadh, 11534, KSA
> >>
> >>
> >>
> >>
> >>
> >>
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org