You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Bolsover <da...@bolsover.com> on 2002/11/20 09:55:47 UTC

Dynamic forward problem

Hi all

I posted this one a few days back but got no response - so I thought I would
have another go - I'll try an improved explanation of the problem.

I need to generate a dynamic forward to an action/script (I have no control over
implementation) on a remote server.

A typical URL for the forward looks like:

"http://www.somesite.com/actionpath?customer=Joe Bloggs&address=Address line 1
Address line 2 Address line 3"

The problem is that the receiving site requires that new line characters in of
the address string are encoded as "&#10;" (the HTML entity for ASCII 10, the new
line character).

If I were to use an on page form, I could generate the required behaviour by
coding like:

<form action="http://www.somesite.com/actionpath" method="POST">
<input type="hidden" name="customer" value="Joe Bloggs">
<input type="hidden" name="address" value="Address line 1&#10;Address line
2&#10;Address line 3">
-- rest of form--

But I don't want to use a form!!  I want to use a dynamic forward

Something like:

StringBuffer sb = new StringBuffer();
sb.append("http://www.somesite/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;

If I try to encode the new line in the above, the forward fails at the first new
line character.

Any ideas please?

David


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>