1 Reply Latest reply on Nov 9, 2006 8:45 AM by peterent

    how to call a JSP page using flex application( when a button or link is clicked)

    sandeepmkumar
      didn't got , as i am a fresher to this FLEX 2.0 , i designed the UI part in flex, but when i click the submit button it has to forward to the JSP page to check against the valid user,password , so how to forward the page to jsp(i mean from flex to jsp) , if u can suggest me with an example, it will be easy for me,

      thanks for ur speedy reply, hopping to get the solution for this issue,

      sandeep.mk@adobe.com
        • 1. Re: how to call a JSP page using flex application( when a button or link is clicked)
          peterent Level 2
          Your JSP is, as far as Flex is concerned, just a data service which it will request and read its response. I'd suggest using <mx:HTTPService>. For example:

          <mx:HTTPService id="authorize" url="validate.jsp" fault="handleFault(event)" result="handleResult(event)">
          <mx:request>
          <userid>{username.text}</userid>
          <password>{password.text}</password>
          </mx:request>
          </mx:HTTPService>

          Flex creates the request: http://{server}.{port}{context.root}/validate.jsp?userid=fred&password=flintstone

          assuming that you have <mx:TextInput id="username" /> and <mx:TextInput id="password" /> components.

          Your Submit button then does: authorize.send()

          (note: you can also pass the request parameters in the send() method - check the Flex docs on HTTPService).

          Flex will listen for the response from your JSP. Typically a JSP would respond with an HTML page, but you don't want to do that for Flex. Your JSP should produce either a simple string ("yes" or "no" or "error" etc) or an XML document.

          The handleResult method can examine the response and do what's necessary.