I have a problem downloading a file using Internet Explorer 7:
I Have a GWT "almost offline" application that works and generates
lots of data that will be written into a PDF report.
The only call that the application do to a servlet is when he needs to
generate the PDF report.
I'm using birt engine to generate the PDF report, and i'm doing a RPC
call to generate the pdf:
On GWT file:
reportService.generateReport(<...lots of params...>, new AsyncCallback
() {
public void onFailure(final Throwable throwable) {
}
public void onSuccess(final Object o) {
Frame downloadFrame = new Frame();
downloadFrame .setSize("0px", "0px");
downloadFrame .setVisible(false);
RootPanel.get().add(downloadFrame );
downloadFrame .setUrl(GWT.getModuleBaseURL() +
"DownloadReportService");
}
});
The report PDF is sucessfully generated and placed on a temporary dir,
where it will be loaded by the DownloadReportService.
This works fine withall firefox versions but in IE7 it doesn't let me
download the file until I accept a raised warning of download blocked
(appears when the address it's not localhost address and with default
ie7 settings).
When i accept the download warning all the information in my
application is clean because IE refreshes the page.
I saw this problem solved on another threads on this list, and i tried
to do it that way, but it didn't work.
(Using Window.open or Window.Location.assign Window.Location.assign).
I want to get rid of the download warning, or if not possible, make
sure the page is not refreshed and the content cleaned! Can anyone
help me?
The DownloadReportService (extends HttpServlet) code:
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
String dir = "C:\\tmp";
String fileName = "test.pdf";
// Open file
File f = new File(dir + "\\" + fileName);
ServletOutputStream op = response.getOutputStream();
ServletContext context = getServletConfig().getServletContext
();
String mimetype = context.getMimeType(fileName);
// Set the servlet response
response.setContentType((mimetype != null) ? mimetype :
"application/octet-stream");
response.setContentLength((int) f.length());
response.setHeader("Content-Disposition", "attachment;
filename=\"" + fileName + "\"");
// Stream to the requester.
byte[] bbuf = new byte[BUFSIZE];
DataInputStream in = new DataInputStream(new FileInputStream
(f));
int length;
while ((length = in.read(bbuf)) != -1) {
op.write(bbuf, 0, length);
}
in.close();
op.flush();
op.close();
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---