by default the '/' root is from your webapp, as it should be. All URLs
should be from '/' that are going to the same webapp. If your going to
another webapp just do an http://.... (Is this last sentence right?)
Don't use ../.. whatever you do! (not easily mutable)
Mike

----- Original Message -----
From: "Will Spies" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Thursday, September 12, 2002 10:49 AM
Subject: Redirecting to a relative URL from root


>
>
> I would like a forward to redirect off of the root context. Normally, if
my
> struts app is in a WAR , let's say MyStrutsApp this forward:
>
>        <forward name = "success"          path = "/mydir/allben_home.jsp"
> redirect = "true"/>
>
> would result in a redirect to
> http://myhost:myport/MyStrutsApp/mydir/allben_home.jsp
>
> I would like to do a redirect to
http://myhost:myport/mydir/allben_home.jsp
>
> Looking at the processActionForward code below this would work if I
removed
> the '/' but by definition this doesn't work since redirecting to a
relative
> link without a slash in front of it will still result in MyStrutsApp
> appearing in the new redirect URL.
>
> How can I do this?
>
>
>
>
>
>
>
>     protected void processActionForward(ActionForward forward,
>                                         ActionMapping mapping,
>                                         ActionForm formInstance,
>                                         HttpServletRequest request,
>                                         HttpServletResponse response)
>       throws IOException, ServletException {
>
>       if (forward != null) {
>           String path = forward.getPath();
>           if (forward.getRedirect()) {
>               if (path.startsWith("/"))
>                     path = request.getContextPath() + path;
>             response.sendRedirect(response.encodeRedirectURL(path));
>           } else {
>             RequestDispatcher rd =
>                 getServletContext().getRequestDispatcher(path);
>                 if (rd == null) {
>
> response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
>                                        internal.getMessage
> ("requestDispatcher",
>                                                            path));
>                     return;
>                 }
>             rd.forward(request, response);
>           }
>       }
>
>
> _______________________
> Will Spies
> Towers Perrin
> Phone: (215)246-7145
> e-mail: [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]>

Reply via email to