5 Replies Latest reply on Nov 18, 2009 4:07 AM by RonnieCR7

    mxml file and jsp


      How to get the data in mxml file from jsp page.

      Please give some example for it .

        • 1. Re: mxml file and jsp
          Richard_Abbott Level 3
          there are a couple of ways to do this, depending how much data you are talking about. Two that come to mind are:
          1) in the JSP scripting, dynamically write out name-value pairs into the flashvars parameter of your SWF setup.

          2) For larger amounts of data, have a separate JSP (with database or web service access Java classes behind it) which generates the data and then serialises it out as the page response. You might want to change the page response type to text/xml or something rather than the default text/html. Since you are in control of both the JSP part and the Flex part, you can easily ensure that whatever method you have used to serialise at the server end you can then deserialise at the client. A simple example would be that the JSP writes out something like
          and the Flex app then unravels this to get name and value. You can easily generalise this to whatever level of complexity you have.
          From the Flex app you then call URLRequest and put the deserialisation code into the response received handler.
          Hope that helps,
          Richard Abbott
          • 2. Re: mxml file and jsp
            pankaj_semwal Level 1
            Do you have any example for this.If yes please send to me.
            • 3. Re: mxml file and jsp
              Richard_Abbott Level 3
              I presume you mean for the second as the first is straightforward deciding what you want to write to the page from JSP.
              For the second, here's a simple example getting some settings from a database call. I'm sure you can fill in the details...
              1) Flex app
              var service:HTTPService;
              var current_date: Date;
              service = new HTTPService();
              current_date = new Date();
              service.url = "get_database_call_list.jsp?d=" + current_date.valueOf();
              // here you would also add on any extra db query parameters
              service.addEventListener(FaultEvent.FAULT , fault_handler);
              service.addEventListener(ResultEvent.RESULT, handler);
              service.resultFormat = "text";
              protected function fault_handler(event: FaultEvent):void
              // handle the error
              } // fault_handler
              protected function handler(event: Event):void
              result_text = event.result as String;
              // validate the result somehow suitable
              database_response = XML(result_text);
              // do something with your XML
              } // try
              catch (error: Error)
              // handle the error
              } // catch
              } // handler

              2) JSP (using Beehive netui tags)
              <netui-data:callPageFlow method="get_data" resultId="result">
              <!-- any extra parameters you have sent -->

              where get_data is a method in your page flow controller file that actually does the DB call.

              Hope that helps,
              • 4. Re: mxml file and jsp
                ntsiii Level 3
                Here is another example(straight jsp):
                • 5. Re: mxml file and jsp

                  Hi Richard,

                  I am trying to export some data into a CSV file format.
                  Im using Flex 2 as a front end. Here the user chooses the component whose data is to be exported and then clicks on the Export button.
                  Im using Struts framework where i get this request, access all the necessary parameters(through an action class) and then in an EJB class i gather the necessary data from the Database using HQL. Once i gather the data successfully i send it to a jsp file where i convert if to CSV format and then make this data available as a downloadable file to the user.


                  The problem that i'm facing is that, when i access the action class through the url i get the download file pop-up. But when i open the flex application, and click the button there is no response. There is no error/exception either since it woult have been caught in the fault handler.  What am i missing?