You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Pe...@materna.de on 2005/07/14 16:37:41 UTC

Forwarding in custom RequestProcessor

Hi!

I have extended the RequestProcessor's processPreprocess() method
in order to perform a simple user authentication mechanism using
cookies. If a cookie identifying a user is found, but the users member-
ship has expired, I would like him to be forwarded/redirected to a
corresponding error page. What is the best way to do this? I tried
the following:

request.getRequestDispatcher( "membershipExpired.jsp" ).forward( request,
response );

which works fine. But this is surely not how struts should work because
I have hardcoded the target in my code, and not configured in my
struts-config.xml for example. So if the error page changes I have to
chnage my code and not only the struts-config.xml. Does anybody know
a better solution? I tried a global-forward like this but it didn't work:

<global-forwards>
    <forward name="nodb" path="/membershipExpired.jsp" />
</global-forwards>

with

request.getRequestDispatcher( "nodb" ).forward( request, response );

Perhaps I made a mistake somewhere...

Peter


--------------------------------------------------

MATERNA GmbH Information & Communications
Vosskuhle 37
44141 Dortmund
Tel:  +49-231-5599-8868
Fax: +49-231-5599-678868

peter.zoche@materna.de
www.annyway.de        www.materna.de
www.annyway.com      www.materna.com

Visit us at the following events:
ACI EUROPE, Munich
June, 22 - 24, 2005

ACI EUROPE, Verona
September, 26 - 28, 2005

CTIA Wireless I.T. & Entertainment 2005, San Francisco
September, 27 - 29, 2005

Con4, Cologne
September, 27 - 29, 2005


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


Re: Forwarding in custom RequestProcessor

Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: <Pe...@materna.de>

> I have extended the RequestProcessor's processPreprocess() method
> in order to perform a simple user authentication mechanism using
> cookies. If a cookie identifying a user is found, but the users member-
> ship has expired, I would like him to be forwarded/redirected to a
> corresponding error page. What is the best way to do this? I tried
> the following:

Have you considered doing this in a Filter instead of extending the
RequestProcessor?  I question the wisdom of tying
authentication/authorization so closely to the Struts framework.

With a Filter, you can stick it in front of anything.  For example, I posted
all the documentation for our internal projects on the web server, but
didn't want to leave it wide open.  Though it's all static HTML, it's
packaged as a .war file, and I was able to drop the same Filter I use in
Struts apps in front of it with a simple change to web.xml.

-- 
Wendy Smoak


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


Re: Forwarding in custom RequestProcessor

Posted by Jeff Beal <jb...@gmail.com>.
request.getRequestProcessor() --> request.getRequestDispatcher()

On 7/14/05, Jeff Beal <jb...@gmail.com> wrote:
> Calling just request.getRequestProcessor() effectively exits the

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


Re: Forwarding in custom RequestProcessor

Posted by Jeff Beal <jb...@gmail.com>.
Calling just request.getRequestProcessor() effectively exits the
Struts environment since the request object doesn't know anything
about struts_config.xml.  You need to use the method and fields of the
RequestProcessor instead.

Try this:

ActionForward expireForward = moduleConfig.findForwardConfig("nodb");
processForwardConfig(request,response,expireForward);
return false;

-- Jeff

On 7/14/05, Peter.Zoche@materna.de <Pe...@materna.de> wrote:
> Hi!
> 
> I have extended the RequestProcessor's processPreprocess() method
> in order to perform a simple user authentication mechanism using
> cookies. If a cookie identifying a user is found, but the users member-
> ship has expired, I would like him to be forwarded/redirected to a
> corresponding error page. What is the best way to do this? I tried
> the following:
> 
> request.getRequestDispatcher( "membershipExpired.jsp" ).forward( request,
> response );
> 
> which works fine. But this is surely not how struts should work because
> I have hardcoded the target in my code, and not configured in my
> struts-config.xml for example. So if the error page changes I have to
> chnage my code and not only the struts-config.xml. Does anybody know
> a better solution? I tried a global-forward like this but it didn't work:
> 
> <global-forwards>
>     <forward name="nodb" path="/membershipExpired.jsp" />
> </global-forwards>
> 
> with
> 
> request.getRequestDispatcher( "nodb" ).forward( request, response );
> 
> Perhaps I made a mistake somewhere...
> 
> Peter
> 
> 
> --------------------------------------------------
> 
> MATERNA GmbH Information & Communications
> Vosskuhle 37
> 44141 Dortmund
> Tel:  +49-231-5599-8868
> Fax: +49-231-5599-678868
> 
> peter.zoche@materna.de
> www.annyway.de        www.materna.de
> www.annyway.com      www.materna.com
> 
> Visit us at the following events:
> ACI EUROPE, Munich
> June, 22 - 24, 2005
> 
> ACI EUROPE, Verona
> September, 26 - 28, 2005
> 
> CTIA Wireless I.T. & Entertainment 2005, San Francisco
> September, 27 - 29, 2005
> 
> Con4, Cologne
> September, 27 - 29, 2005
> 
> 
> ---------------------------------------------------------------------
> 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: Forwarding in custom RequestProcessor

Posted by "Mulligan, Scott H" <sc...@eds.com>.
I extended the RequestProcessor to forward between two web applications. The following code is what I use to forward to an action that the other web application has. Then the other web application can define an action that can handle forwarding to whatever jsp it wants.
if (forward.getName().startsWith("common_"))
{
getServletContext().getContext("/thinClient/common.do").getRequestDispatcher("/common.do").forward(request,response); 
return;
}
Scott

 



From: Peter.Zoche@materna.de
Sent: Thu 7/14/2005 10:37 AM
To: user@struts.apache.org
Subject: Forwarding in custom RequestProcessor


Hi!

I have extended the RequestProcessor's processPreprocess() method
in order to perform a simple user authentication mechanism using
cookies. If a cookie identifying a user is found, but the users member-
ship has expired, I would like him to be forwarded/redirected to a
corresponding error page. What is the best way to do this? I tried
the following:

request.getRequestDispatcher( "membershipExpired.jsp" ).forward( request,
response );

which works fine. But this is surely not how struts should work because
I have hardcoded the target in my code, and not configured in my
struts-config.xml for example. So if the error page changes I have to
chnage my code and not only the struts-config.xml. Does anybody know
a better solution? I tried a global-forward like this but it didn't work:

<global-forwards>
    <forward name="nodb" path="/membershipExpired.jsp" />
</global-forwards>

with

request.getRequestDispatcher( "nodb" ).forward( request, response );

Perhaps I made a mistake somewhere...

Peter


--------------------------------------------------

MATERNA GmbH Information & Communications
Vosskuhle 37
44141 Dortmund
Tel:  +49-231-5599-8868
Fax: +49-231-5599-678868

peter.zoche@materna.de
www.annyway.de        www.materna.de
www.annyway.com      www.materna.com

Visit us at the following events:
ACI EUROPE, Munich
June, 22 - 24, 2005

ACI EUROPE, Verona
September, 26 - 28, 2005

CTIA Wireless I.T. & Entertainment 2005, San Francisco
September, 27 - 29, 2005

Con4, Cologne
September, 27 - 29, 2005


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