Two Laptop Bag*
The moose likes Flex and the fly likes Communication between Java Servlet and Flash Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Flex
Bookmark "Communication between Java Servlet and Flash" Watch "Communication between Java Servlet and Flash" New topic
Author

Communication between Java Servlet and Flash

Rob Proesmans
Greenhorn

Joined: Aug 16, 2012
Posts: 8
Dear programming friends,

I have made an jsp/servlet application to manage appointments.

As an extra:
I am making a FLEX (flash) interface In Adobe flash builder, to manage these appointments with drag and drop functions etc..
But I have a problem: Is it possible to communicate in flash with java Servlets?

Maybe I have to export all my arraylists and parameters to arraycollections in flex (So I can build up my flash website with imported arraylists), or is there an easier way?

When I would make an appointment in flash, my servlet requires some parameters, is it possible to send them through?

I hope someone can help me, I have been googling this for hours. I haven't found a solution yet.
There was an earlier topic about this on javaranch, but the URL links they gave to help the guy out are all dead right now :'(

Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11437
    
  85

Have you looked at the mx:HTTPService tag?

Personally I would probably go with a RESTful web service on the Java side, but it is possible to interface with your existing web application if you must.


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11437
    
  85

Assuming you are running the Flex app directly on top of the existing web application without adding a REST interface, here is some very simplistic code showing calling a web application through Flex:



Since you control the server, you can probably make sure the output is well formed XML, which would allow you to set the resultFormat to e4x and process it as an XML document.

The important thing is the answer to your question - you can see that on line 5 I am declaring a call to the HTTPService provided by Bing (because it is shorter to type than Google ) at http://www.bing.com/search. Then I pass the parameter "q" with the value "cheese" at line 7.
Rob Proesmans
Greenhorn

Joined: Aug 16, 2012
Posts: 8
Ok thank you man, so you suggest to export the data from the servlet (arraylists with objects in it) to XML.
And then import XML to Flex, is this the proper way to do it?
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11437
    
  85

You might be interested in Flex chart from XML data using HttpService with Java Servlets - while the servlet code is pretty ugly, the overall concept shows what you need.
 
Consider Paul's rocket mass heater.
 
subject: Communication between Java Servlet and Flash