Hi,
im trying to create a web app thats allow me to download a file
generated from server (not stored).
on server side:
ich have implemented a download servlet below:
public void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
ServletOutputStream servletOStream = null;
ByteArrayOutputStream baOPStream = null;
try {
baOPStream = //generated file as stream
if (baOPStream != null) {
StringBuffer sbFilename = new StringBuffer();
sbFilename.append("MSP_");
sbFilename.append(System.currentTimeMillis());
sbFilename.append(".ppt");
response.setContentLength((int) baOPStream.size());
response.setContentType("application/octet-stream");
response.setHeader("content-disposition", "attachment;
filename=\""
+ sbFilename + "\"");
servletOStream = response.getOutputStream();
servletOStream.write(baOPStream.toByteArray());
servletOStream.flush();
}
} catch (IOException ioe) {
throw new ServletException(ioe.getMessage());
} finally {
servletOStream.close();
baOPStream.close();
}
}
public void doPost(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
doGet(request, response);
}
on the client side i used a Requestbuilder to send a string to the
server as follow:
RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, "/
procedmsp/download");
ExportRequestHandler exportHandler = new ExportRequestHandler(){
public void onError(Request req, Throwable exception) {
//error handling
}
public void onResponseReceived(Request req, Response resp) {
//.....get the response and start the download????
}
};
builder.setCallback(exportHandler);
builder.setRequestData(data); //String data to send
builder.send();
the question is. i dont know how to start the file download. any idee?
--
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.