I have a very difficult situation, nothing is helping.
I have a servlet running in glassfish server.
protected void doGet( HttpServletRequest request, HttpServletResponse response )
throws ServletException, IOException {
String filename = request.getParameter( "file" );
try {
ServletOutputStream printStream = response.getOutputStream();
File aFile = new File( filename );
try {
printStream.print( getContents( aFile ) );
aFile.delete();
} catch ( IOException e ) {
printStream.print( printWarning() );
}
} catch ( Exception e ) {
logger.error( e.getMessage(), e );
}
}
I am invoking this servlet from Adobe Air application and want to display the content of the file (passed as a parameter) into a Adobe Air window. If I use navigateToURL() method, then Adobe Air application is opening an internet browser window and successfully displaying the content. But if I use the following A3 code -
var service:HTTPService = new HTTPService();
service.resultFormat = "xml";
service.url="http://server.com/..../servletUrl";
service.method = URLRequestMethod.GET;
var params:Object = new Object();
params["file"] = "/tmp/xyz.html";
service.addEventListener(Event.COMPLETE, pageLoadComplete);
service.send(params);
public function pageLoadComplete(event:Event):void
{
log.debug("Received event");
var result:String = URLLoader(event.currentTarget).data.toString();
log.debug("Result =" , result);
}
Then I am not getting any Result! This is obvious because the servlet is only printing the content and nothing else.
I cannot change the servlet code, I can only change the Adobe Air framework so that it can work with any backend code.
So what is causing the demarcation that servlet response is being printed on the browser (Chrome) window and not on Adobe Air window? And how to fix it?
Thanks in advance...