Expand my Community achievements bar.

how to send results to actionscript using java

Avatar

Level 1
Hi,

I do RPC using HttpService.

In my situation, I need to send results from Java code to
Flex Action script. I have defined a Java Servlet receiving data
from Flex application, then it processes with the data, finally the
Servlet is supposed to send some feedbacks to the client(Flex).



My question is that how can I define codes in doPost() method
that the following function will get "result" from the Java side.



public static function httpResult(event:ResultEvent):void

{

var result:Object = event.result;

//Do something with the result.

if (result.toString() == "success")

{

resultMessage.text = "Login Success";

}

resultMessage.text = "Invalid User";

}
1 Reply

Avatar

Level 1
Hi,

Try this: If you are sending a simple text as "sucess" or
"error" after doing some process in the servlet..

set your content type to "text/plain" and simply
println(<data to be sent>);

In the flex application, get the result text that the servlet
send using:

resultString = String(httpUrl.lastResult);

where httpUrl is the id of the HTTPService. Now you can
compare what the servlet send by:

if(resultString=="sucess") {

......

}

Hope this solves your problem :)

Regards,

-- Abdel Olakara


http://olakara.googlepages.com


http://technopaper.blogspot.com