0

I want to retrieve data from a Database and display inside a datagrid in a Flex web application. The way I'm thinking of doing it is :

  1. Send the Query data from .mxml file to the .jsp page using HTTPService.
  2. In the .jsp, connect to the database and retrieve the data using select statements.
  3. send the results back to the .mxml using HTTPService.

I know what to use but I have an ambiguity. In the (.mxml) I use xxx.send() to send the data. What do I use in the (.jsp) to send it back ?

Also, I know that I should store the results in an XML in the .jsp file, but how to do that ?

1
  • I don't know the Java syntax well. Usually your server side code will be in a method/function in the server side file with a specified return type. You'll send data back using 'return myValue'. If you're just generating a page--not calling a service--then your result will be the screen output; which will be returned as a string. Commented Jul 9, 2011 at 12:53

1 Answer 1

1

You just output the XML data directly to the screen as you would with any other jsp web page. Pretend you're making a jsp to display some html, same concept applies, just display the XML instead.

  • yourpage.jsp :

    <% java.util.Date date = new java.util.Date(); %>
    <root><time><%= date %></time></root>
    

When you receive it, it will be stuffed into the result event based on the result format. For XML like you're talking, you'll want your service to look something like :

<mx:HTTPService id="myService" url="yourpage.jsp" method="GET" 
    resultFormat="e4x" result="myServiceResponse(event)" fault="httpFaultHandler(event)" showBusyCursor="true"/>

Then your response method looks something like this :

private function settingsResponse( e : ResultEvent) : void {
    myXML = e.result as XML;
    mx.controls.Alert.show('current server date/time is ' + String(myXML.time) );
    //   ...do whatever you want with your xml now!...
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.