0 Replies Latest reply on Jul 19, 2006 10:34 AM by ramu_123

    How can open a Stream?

    ramu_123
      Hi all,

      I have a requirement to open Steam coming from J2EE layer. More
      clearly, I've MXML file where i'm requesting a servlet using
      HTTPService. Here is the code

      <mx:HTTPService id="exportRequest" useProxy="false"
      url="/inventory/search.do" showBusyCursor="true">
      <mx:request>
      <Action>Export</Action>
      <exportMode>pdf</exportMode>
      </mx:request>
      </mx:HTTPService>

      And here is my struts application

      ByteArrayOutputStream baos =new ByteArrayOutputStream();

      if(exportMode.trim().equalsIgnoreCase("pdf")) {
      response.setContentType ("application/pdf");
      response.setHeader ("Content-Disposition", "attachment;
      filename=\"SearchResults.pdf\"");
      try{
      JasperExportManager.exportReportToPdfStream(jasperPrint, baos);
      }catch(JRException jre) {}

      response.setContentLength(baos.size());
      ServletOutputStream outStream = response.getOutputStream();
      baos.writeTo(outStream);
      baos.close();
      outStream.flush();
      it works fine when i made a call from HTML. I've to get a popup
      contains "Save" "Open" and "Cancel" options.

      When I try to do this i'm getting an ERROR message..

      [RPC Fault faultString="Error #1090: XML parser failure: element is
      malformed." faultCode="Client.CouldNotDecode" faultDetail="null"]
      at
      mx.rpc.http::HTTPService/ http://www.adobe.com/2006/flex/mx/internal::p
      rocessResult()
      at
      mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::re
      sultHandler()
      at mx.rpc::Responder/result()
      at mx.rpc::AsyncRequest/acknowledge()
      at ::DirectHTTPMessageResponder/completeHandler()
      at
      flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEv
      entFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at flash.net::URLLoader/flash.net:URLLoader::onComplete()