How to send error message from servlet to flex FileReference in Flex When download
I use fileReference.download() to download files. The fileReference send request to java servlet.In servlet, some error may be checked. For example error - 'File not found'. I want to send the error to flex side. I tried lots of methods,but fileReference in flex can't receive them. Such as
response.sendError(HttpServletResponse.SC_NOT_FOUND, "File not found");
or
PrintWriter out = resp.getWriter(); out.print("File not found");
It seems fileReference can't triggers event 'DataEvent.UPLOAD_COMPLETE_DATA' a开发者_JAVA百科nd 'HTTPStatusEvent.HTTP_STATUS'. Can somebody tell me how to get servlet error message in fileReference. Thanks
I do not believe FileReference.download dispatches a HttpStatus event, nor exposes status code.
You can only listen for IOErrorEvent.
Think there is no solution. I tried hard several ways like responding with 500, sendError over response with message, returning XML document (but you don't have control over downloaded content). I solved the issue by creating a "allround error message" that fits to most situation (you have no permission or content is unavailable...)
Other solution is to download with navigateTo but then you need to open a browser window.
精彩评论