You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by bramsomers <br...@skynet.be> on 2006/12/08 12:25:30 UTC

forward request to struts action on other server

Hi all,

I have two servers, each running the sun appliction server (9.0). I've build
a webapplication, and know I want to forward requests from the first to the
second application server.

In my LoginAction on the first server I put this in the code:

return new ActionForward("http://" + server.getUrl() +
":8080/project/Login.do", false);

put that gives me the error:
java.lang.IllegalArgumentException: Path
http://192.168.1.135:8080/project/Login.do does not start with a "/"
character

I don't know what I do wrong, does anybody know a way to do this?

It need to be forwarded, so that the action on the other server can access
the parameters in the form.

Thanks a lot!

Ps: if it's not possible like I explained here above, is there any other
solution to do this?

Bram
-- 
View this message in context: http://www.nabble.com/forward-request-to-struts-action-on-other-server-tf2780049.html#a7756157
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: forward request to struts action on other server

Posted by Laurie Harper <la...@holoweb.net>.
bramsomers wrote:
> Hi all,
> 
> I have two servers, each running the sun appliction server (9.0). I've build
> a webapplication, and know I want to forward requests from the first to the
> second application server.

You can't forward a request between two separate applications, whether 
they be deployed on the same or different containers. You will need to 
use a redirect instead.

> In my LoginAction on the first server I put this in the code:
> 
> return new ActionForward("http://" + server.getUrl() +
> ":8080/project/Login.do", false);
> 
> put that gives me the error:
> java.lang.IllegalArgumentException: Path
> http://192.168.1.135:8080/project/Login.do does not start with a "/"
> character
> 
> I don't know what I do wrong, does anybody know a way to do this?

Setting the second argument to 'true' instead of 'false' may work. 
Failing that, you'll need to manually perform a redirect.

> It need to be forwarded, so that the action on the other server can access
> the parameters in the form.

Unfortunately, as noted above, that's not possible. You do have some 
options, though; see below:

> Thanks a lot!
> 
> Ps: if it's not possible like I explained here above, is there any other
> solution to do this?

If you don't need to process the form on server1 before forwarding 
(redirecting) to server2, you could have the form submit directly to 
server2. That's probably the easiest solution if it works for you.

Failing that, the only thing you can do is to construct the request to 
server2 in such a way as to include the form data. If there's not much 
data, you may be able to build a query string to append to your redirect 
URL; otherwise, it gets trickier since you'll have to construct and send 
a POST request to server2. In that case, server1 ends up having to proxy 
the request/response, which is messy.

You may want to restate your question in terms of what you are trying to 
achieve, as there may be an alternative approach that would work better.

L.


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