struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nielsen, Jim" <jim.niel...@eds.com>
Subject RE: can't redirect out of the context
Date Wed, 25 Jun 2003 20:06:04 GMT


Nick,
I ran into a need to do the same.

1. I believe you need Struts 1.1.
2. In my Action I have code that gets a destination url from a properties
file based on parameters.

// determine the destination based on the params in the LinkParams
// create a LinkMapper based on Div key

	LinkMapper myLinkMapper =
LinkMapperManager.getLinkMapper(aLinkReq.getDiv());
	String newDest = myLinkMapper.findRedirectUrl(aLinkReq);

	ActionForward af;
	if (newDest == null)
	{
		af = mapping.findForward("DefaultDest");
		af.setRedirect(true);
		newDest = af.getPath();
	}
	else
	{
		af = new ActionForward(newDest, true);
	}
	// do a redirect to the destination
	return af;


My action in the struts-config.xml file looks like this.
    <!-- Do Redirect! -->
    <action    path      = "/Redirector"
               type      = "redirector.actions.RedirectorAction"
               name      = "RedirectorForm"
               scope     = "request"
               validate  = "false"
    >
     	<forward name="DefaultDest" path="http://www.yahoo.com"
contextRelative="true" redirect="true" />
    </action>

Hope it helps.

Jim Nielsen
EDS
jim.nielsen@eds.com
phone: (810) 234-4025 (8-394)
AOL IM: JimRNielsenEDS
jabber id: jim.nielsen@eim.eds.com

GLTC-B
4100 S. Saginaw., MC:  485-303-321
Flint, MI  48557


-----Original Message-----
From: Afshartous, Nick [mailto:nick.afshartous@proactcorp.com]
Sent: Wednesday, June 25, 2003 2:04 PM
To: 'struts-user@jakarta.apache.org'
Subject: can't redirect out of the context



Hi,

I'm trying to have an Action redirect to yahoo using the lines
below. However, the servlet context is getting prepended
and the error is

   The requested resource (/acme/www.yahoo.com) is not available.

Setting contextRelative did not make a difference.

Thanks for any suggestions.  
--
    Nick



	
 ActionForward forward = new RedirectingActionForward("www.yahoo.com");

 forward.setContextRelative(false);

 return forward;

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


Mime
View raw message