2 Replies Latest reply on May 21, 2012 3:10 AM by Hunternif

    HTTPService redirect

    bldrbldr Level 1
      I'm trying to use J2EE Servlet form based authentication by posting to the well-known url j_security_check. In my web.xml file I specify FORM authentication and my custom Flex login page. Upon accessing a protected resource, I am redirected to my login page as expected. Upon successful login the server sends an HTTP redirect back to the protected resource, but I can't figure out how to capture this redirect. My fault method will get called if I use the wrong password, however the result method does not get called, probably because it is a redirect. The server is actually authenticating the user, because if I access the protected resource again in the same session it works fine.

      How can I get the HTTPService to follow a redirect, or at least how can I get notification that the call has completed?

      I'm using Tomcat in JBoss and the following code demonstrates the problem, even without configuring web.xml.


      <?xml version="1.0" encoding="utf-8"?>
      xmlns:mx=" http://www.adobe.com/2006/mxml"

      import mx.rpc.events.FaultEvent;
      import mx.rpc.events.ResultEvent;
      private function onResult(event:ResultEvent):void {
      // Never reached
      private function onFault(event:FaultEvent):void {
      // Called after unsuccessful login

      <mx:HTTPService id="loginService" url="j_security_check" method="POST" result="onResult(event)" fault="onFault(event)">

      <mx:Panel id="panel" title="Login">

      <mx:Form id="form">
      <mx:Label id="directions" text="Please Login:"/>
      <mx:FormItem label="Username">
      <mx:TextInput id="username"/>
      <mx:FormItem label="Password">
      <mx:TextInput id="password" displayAsPassword="true"/>

      <mx:FormItem id="passwordConfirmItem" label="Confirm:" visible="false">
      <mx:TextInput id="passwordConfirm" displayAsPassword="true"/>
      <mx:Spacer width="100%" id="spacer1"/>
      <mx:Button label="Login" id="login" click="loginService.send();"/>