I want to redirect mxml file to servlet and print the code on servlet but when i use navigate to url code then the output shows null values of the textinput fields in the servlet page, please help me clerify the problem the basic coding of mxml and servlet are given below
The MXML File
<s:Application...>
<fx:Script>
<![CDATA[
import flash.net.navigateToURL;
import mx.controls.*;
import mx.events.Request;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
public function resultHandler(event : ResultEvent):void
{
navigateToURL(new URLRequest('Srvlt'),'_self')
}
public function faultHandler(event : FaultEvent):void
{
Alert.show("error");
}
]]>
</fx:Script>
<fx:Declarations>
<s:HTTPService id="service" url="Srvlt" result="resultHandler(event)" fault="faultHandler(event)" method="GET" showBusyCursor="true" resultFormat="text">
<s:request xmlns="">
<email>{email.text}</email>
<pass>{pass.text}</pass>
</s:request>
</s:HTTPService>
</fx:Declarations>
<s:VGroup verticalAlign="middle">
<s:FormItem label="E-mail : ">
<s:TextInput id="email" />
</s:FormItem>
<s:FormItem label="Password :">
<s:TextInput id="pass" displayAsPassword="true" />
</s:FormItem>
<mx:Button label="Submit" click="service.send()" />
</s:VGroup>
</s:Application>
The servlet’s get method coding is as follows
String e = request.getParameter("email");
String p = request.getParameter("pass");
String resul;
PrintWriter out = response.getWriter();
resul = "Hi i am servlet, your username is " + e + " & password is " + p + ". are they correct ?";
out.print(resul);
You’re sending 2 different requests in your application. The first one is
HTTPService, the second one isURLRequest.When you handle result, you can get your response string via
ResultEventobjectYou can work now with this string.
But if you want to open new page with the result text, then you don’t need to use
HTTPService. UseURLRequestclass.So, you’re doing it wrong now. Don’t send 2 requests. Choose either
HTTPServiceand handling result inside the application, ornavigateToURLandURLRequestif you want just to display response in new window.