Hallo Simon,

Yes You have understood right: I want the user's browser to call
another server and dont want to continue processing my application
afterwards.

I also have thought about the JavaScript solution.
But using a js solution generally I will write the xml-data into the
user's html. I did'nt like to do that, because this (xml-)data grants
You access to the other application. For this reason I wanted to hide
the xml-data. But using get-Parameters the xml-data is visible the
same.


Maybe should think about a ajax- functionality like this:

I use a commandbutton that supports ajax-request and a hidden form
that makes a post-request.
When the user clickes the commandbutton i can fill the data of the
form via ajax and then in an after-ajax-event click the submit-button
of the form via JavaScript. Do You think this will work?

I hoped, there would be an more easy way....

Thank You for Your help.

Regards


Georg

2009/4/21 Simon Kitching <[email protected]>:
> Georg Füchsle schrieb:
>> hallo,
>>
>>
>> I have to call another application out from JSF.
>> To call this application i have to send (xml) data via post to the
>> start-url of this application.
>>
>> I found some example on the web:
>>
>> <code>
>> ExternalContext extContext =
>> FacesContext.getCurrentInstance().ctx.getExternalContext();
>> String name = URLEncoder.encode("INTERFACENAME", "utf-8");
>> String someData = "<?xml version='1.0' encoding='UTF-8'?> <data>
>> <caller value='giofyxle'/><app value='2'/></data></xml>";
>> String value = URLEncoder.encode(someData , "UTF-8");
>> String viewId = "http://www.server.com/startapp/index.html"+ '?' +
>> name + "=" + value;
>> String urlLink = extContext.encodeActionURL(viewId);
>> extContext.redirect(urlLink);
>> </code>
>>
>>
>> I tried this code. its calls the new application, but the data is sent via 
>> GET:
>>
>> http://www.server.com/startapp/index.html?INTERFACENAME==%3C%3Fxml+version%3D%271.0%27+encoding.....
>>
>> So the intefacedata is easily be read by the user. Has anyone any idea
>> how i can make a rediract with POST data?
>
> When you say "call another application out", do you mean that you want
> the *user's browser* to send a POST command to some other server, and
> then display the result returned from that server (without any further
> processing)?
>
> HTTP provides no way to do this; the http-redirect facilities only do
> GET commands. See the HTTP specification for more details. What your
> code above does (extContext.redirect) just generates an http redirect
> response, and the user's browser then processes this response and does
> the redirect.
>
> HTML provides no way to do this either AFAIK.
>
> JSF just uses HTTP and HTML, so JSF also has no way to do this. I think
> you will need to use javascript, ie generate an HTML page that contains
> an html <form> with the fields you want, and some javascript that then
> does document.getElementById(formId).submit() or something similar.
>
>
> Or does "call another application out"mean that after a JSF submit, you
> want *your server* to send a POST command to some other server, then
> process the result before sending back a new page to the user? You can
> use the apache commons-httpclient library to do things like this.
>
> Regards,
> Simon
>
> --
> -- Emails in "mixed" posting style will be ignored
> -- (http://en.wikipedia.org/wiki/Posting_style)
>

Reply via email to