Question

I'm using Flash 4.0 as UI tier, and I'm trying to send data to the server side, which runs on Tomcat. I wrote a servlet that the calls are directed to it. But I do not understand how can I see the data that was sent from the flash tier. to clarify, hereby example:

Flash tier:

<fx:Declarations>
    <s:HTTPService 
        id="setCustomerDataService" 
        url="http://localhost:8080/AnalyticsPortalWebUI-1.0/setCustomerData" 
        useProxy="false" method="POST" resultFormat="text"
        result="onSetCustomerDataResult(event)"
        fault="fault(event)"> 
    </s:HTTPService>

</fx:Declarations>

<fx:Script>
    <![CDATA[

        private function onSubmitCustomerDataClick(event:MouseEvent):void
        {
            var item:UsageInfoItem = new UsageInfoItem();
                        ....
            //i use JSON to encode,but it's not related to my question
                            var data:String = JSON.encode(item);
            //query:
            setCustomerDataService.send(data);
        }


    ]]>
</fx:Script>

my Servlet:

public void service(HttpServletRequest httpRequest, HttpServletResponse httpResponse)
{
   //how can I retrieve "data" from flash here?
}

so my question - how can I retrieve "data" from Flash, in my Servlet?

thanks, Ohad

Was it helpful?

Solution

found the answer - so I share it here:

in the flash side:

        private function onSubmitCustomerDataClick(event:MouseEvent):void
        {
            var item:UsageInfoItem = new UsageInfoItem();
                            ....
                            **//this is how you do it:**
            var params:Object = {};

            var data:String = JSON.encode(item);
            params["paramName"] = data;
            //query:
            setCustomerDataService.send(params);
        }

in the server end:

public void service(HttpServletRequest httpRequest, HttpServletResponse httpResponse)
{
   String customerDataJsoned = httpRequest.getParameter("paramName");

   if(customerDataJsoned != null)
   {
       ObjectMapper mapper = new ObjectMapper();
       CustomerData customerData = mapper.readValue(customerDataJsoned, CustomerData.class);
       String customerId = customerData.getCustomerId();
   }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top