You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "DuBois, Joseph" <Jo...@childrens.harvard.edu> on 2004/08/05 16:46:29 UTC

Having Action forward to another applications action

Heylo all,
 
Problem: I have two related applications, one which handles
authentication (chlogin) and a second application which handles managing
a menu (chmenu).  When the user logs out of the menu application I would
like to forward them to the logout of the authentication app.
 
In my menu application struts-config.xml file I have the following
action declaration. On success of logout of the menu (clearing their
menu session) I then forward them to the authentication(login)
application to log them out totally. The following Action works fine
under IE/Netscape, but under Safari it can't find it (Safari doesn't
like URLs with HTTP: without a server).
 
    <action    path="/logout"
               type="org.chboston.web.action.LogoutAction">
       <forward name="success" path="http:/chlogin/logout.do"
redirect="true" />
    </action>
 
 
If I use the following, STRUTS attempts to call the action under the
menu application (chmenu).
 
    <action    path="/logout"
               type="org.chboston.web.action.LogoutAction">
       <forward name="success" path="/chlogin/logout.do" redirect="true"
/>
    </action>
 
 
I can use the following use the following, but if we add modules in the
future, this would break and I don't feel comfortable doing it this way.
 
    <action    path="/logout"
               type="org.chboston.web.action.LogoutAction">
       <forward name="success" path="../chlogin/logout.do"
redirect="true" />
    </action>
 
 
Is there any way to have a action forward to an action of another
application. Note: the reason I don't use a fully qualified URL is
because the application resides behind a load switch and I need to call
the application on the same machine that they hit for th CHMenu.
 
Any help would be greatly appreciated.
Joe


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


Re: Having Action forward to another applications action

Posted by Kishore Senji <ks...@gmail.com>.
If your forward path starts with a /, RequestProcessor's
processForwardConfig() treat's it relative to the current contextpath
and so you would end up hitting an url in the same application. If
your forward path doesn't start with a /, response.sendRedirect()
which is used by processForwardConfig(), treats the url relative to
the current request URI, so, you would again end up hitting an url in
the same application.

One solution would be redirecting yourself in your Action, 

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){

   // logic 
   response.sendRedirect("/chlogin/logout.do");
   return null;
}

Thanks,
Kishore Senji.

On Thu, 5 Aug 2004 10:46:29 -0400, DuBois, Joseph
<jo...@childrens.harvard.edu> wrote:
> Heylo all,
> 
> Problem: I have two related applications, one which handles
> authentication (chlogin) and a second application which handles managing
> a menu (chmenu).  When the user logs out of the menu application I would
> like to forward them to the logout of the authentication app.
> 
> In my menu application struts-config.xml file I have the following
> action declaration. On success of logout of the menu (clearing their
> menu session) I then forward them to the authentication(login)
> application to log them out totally. The following Action works fine
> under IE/Netscape, but under Safari it can't find it (Safari doesn't
> like URLs with HTTP: without a server).
> 
>    <action    path="/logout"
>               type="org.chboston.web.action.LogoutAction">
>       <forward name="success" path="http:/chlogin/logout.do"
> redirect="true" />
>    </action>
> 
> If I use the following, STRUTS attempts to call the action under the
> menu application (chmenu).
> 
>    <action    path="/logout"
>               type="org.chboston.web.action.LogoutAction">
>       <forward name="success" path="/chlogin/logout.do" redirect="true"
> />
>    </action>
> 
> I can use the following use the following, but if we add modules in the
> future, this would break and I don't feel comfortable doing it this way.
> 
>    <action    path="/logout"
>               type="org.chboston.web.action.LogoutAction">
>       <forward name="success" path="../chlogin/logout.do"
> redirect="true" />
>    </action>
> 
> Is there any way to have a action forward to an action of another
> application. Note: the reason I don't use a fully qualified URL is
> because the application resides behind a load switch and I need to call
> the application on the same machine that they hit for th CHMenu.
> 
> Any help would be greatly appreciated.
> Joe
> 
> ---------------------------------------------------------------------
> 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