This is a known issue and is currently being worked on in 1.1.

David






From: Kris Schneider <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: Struts Users Mailing List <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
Subject: RE: How to Redirect ???
Date: Mon, 18 Nov 2002 14:11:19 -0500

By the way, you can't do that in 1.1. After startup the configutation is frozen
(and ActionMapping.addForward doesn't exist anymore).

In 1.0.2, Struts will examine the redirect attribute and, if it's set to true,
will then examine the path attribute to see if it starts with a "/". Only if it
does is the context prepended to the path. So, in 1.0.2 it looks like Struts
behaves the way wolfgang expected. In 1.1, however, the path attribute is
interpreted as strictly module- or context-relative. In other words, the
context is *always* prepended to the path. I'm not sure if this was driven by
the sub-module feature, but it's one of those places where the behavior has
changed.

Quoting David Bolsover <[EMAIL PROTECTED]>:

>
> Hi all
>
> For what it is worth.
>
> This works in an Action:
>
> Good for building dynamic forwards
>
> StringBuffer sb = new StringBuffer();
> sb.append("http://www.someurl/actionpath?";);
> sb.append("&customer=" + customer.getName());
> sb.append("&address=" + customer.getAddress());
>
> etc..
>
> ActionForward forward = mapping.findForward("success");
> forward.setPath(sb.toString);
> forward.setRedirect(true);
> mapping.addForward(forward);
>
> return forward;
>
> > -----Original Message-----
> > From: Kris Schneider [mailto:[EMAIL PROTECTED]]
> > Sent: 18 November 2002 17:47
> > To: Struts Users Mailing List
> > Subject: Re: How to Redirect ???
> >
> >
> > Another thought is that you could still use a <forward> element to define
> an
> > external resource:
> >
> > <global-forwards>
> > <forward name="external.yahoo" path="http://www.yahoo.com"/>
> > <forward name="external.sun" path="http://www.sun.com"/>
> > </global-forwards>
> >
> > Then, in an Action:
> >
> > ActionForward yahoo = mapping.findForward("external.yahoo");
> > response.sendRedirect(response.encodeRedirectURL(yahoo.getPath()));
> >
> > Never tried it, but seems like it should work. Just understand that those
>
> > forwards can't be used by the standard Struts machinery.
> >
> > Quoting Brian Hickey <[EMAIL PROTECTED]>:
> >
> > > Wolfgang,
> > >
> > > Redirect outside of an app can be done a number of ways.
> > >
> > > One suggestion:
> > >
> > > Map your redirect to a class that creates the forwardURL.
> > > Put the forwardURL into request scope.
> > > Create a JSP that does nothing but the redirect. Map to it in
> > > struts-config.
> > > use the jsp:usebean and <meta http_equiv> tag to perform the external
> > > redirect.
> > >
> > > The advantage of this method is logging which can be done in the class
> and
> > > you have no context other than what you specify in the <meta
> http-equiv>
> > > tag.
> > >
> > >
> > > Brian
> > >
> > >
> > >
> > > ----- Original Message -----
> > > From: "Kris Schneider" <[EMAIL PROTECTED]>
> > > To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> > > Sent: Monday, November 18, 2002 11:58 AM
> > > Subject: Re: How to Redirect ???
> > >
> > >
> > > > That's not what the contextRelative attribute means. Here's the
> snippet
> > > from
> > > > the 1.1 DTD:
> > > >
> > > > contextRelative Set this to "true" if, in a modular application, the
> > > path
> > > > attribute starts with a slash "/" and should be
> > > considered
> > > > relative to the entire web application rather than
> the
> > > module.
> > > > Since Struts 1.1.
> > > > [false]
> > > >
> > > > The redirect attribute only determines if RequestDispatcher.forward
> or
> > > > HttpServletResponse.sendRedirect is used. In either case, the path
> > > attribute is
> > > > always either module-relative or context-relative.
> > > >
> > > > I think you'll have to use something like
> > > HttpServletResponse.sendRedirect
> > > > directly in your Action to redirect outside your app's context.
> > > >
> > > > Quoting "Trieu, Danny" <[EMAIL PROTECTED]>:
> > > >
> > > > > Isn't there is a contextrelative attribute in the <forward/> tag
> where
> > > you
> > > > > can set to 'true'?
> > > > >
> > > > > -----Original Message-----
> > > > > From: wolfgang [mailto:[EMAIL PROTECTED]]
> > > > > Sent: Monday, November 18, 2002 8:15 AM
> > > > > To: [EMAIL PROTECTED]
> > > > > Subject: How to Redirect ???
> > > > >
> > > > >
> > > > > Hi there,
> > > > >
> > > > > I wanna make users redirect(not forward) to http://www.yahoo.com ,
> but
> > > > > cannot make it...
> > > > >
> > > > > I added the following elements in the struts-config.xml
> > > > >
> > > > > <global-forwards>
> > > > > <forward name="finish" path="http://www.yahoo.com"; redirect="true"
> />
> > > > > </global-forwards>
> > > > >
> > > > > and the following code in the execute method of the Action class.
> > > > >
> > > > > return mapping.findForward("finish");
> > > > >
> > > > > but It doesn't work.
> > > > > Struts attempts to make users redirect to the
> > > > > "/test_webapp/http://www.yahoo.com"; where /test_webapp is the name
> of
> > > my
> > > > > web
> > > > > application.
> > > > >
> > > > > How can I make it ??
> > > > >
> > > > > Thanks in advance.
> > > > >
> > > > > wolfgang-
> > > > >
> > > > >
> > > > > --
> > > > > wolfgang <[EMAIL PROTECTED]>
> > > > >
> > > > >
> > > > > --
> > > > > To unsubscribe, e-mail:
> > > > > <mailto:[EMAIL PROTECTED]>
> > > > > For additional commands, e-mail:
> > > > > <mailto:[EMAIL PROTECTED]>
> > > > >
> > > > > --
> > > > > To unsubscribe, e-mail:
> > > > > <mailto:[EMAIL PROTECTED]>
> > > > > For additional commands, e-mail:
> > > > > <mailto:[EMAIL PROTECTED]>
> > > > >
> > > >
> > > >
> > > > --
> > > > Kris Schneider <mailto:[EMAIL PROTECTED]>
> > > > D.O.Tech <http://www.dotech.com/>
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > <mailto:[EMAIL PROTECTED]>
> > > > For additional commands, e-mail:
> > > <mailto:[EMAIL PROTECTED]>
> > > >
> > > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > > <mailto:[EMAIL PROTECTED]>
> > > For additional commands, e-mail:
> > > <mailto:[EMAIL PROTECTED]>
> > >
> >
> >
> > --
> > Kris Schneider <mailto:[EMAIL PROTECTED]>
> > D.O.Tech <http://www.dotech.com/>
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
> >
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>


--
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech <http://www.dotech.com/>

--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail


--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to