Re: File Download in GWT
I'm not sure what you mean. I think mean you want to send information with the link (no the iframe, because it is used to receive the response), so you have to add the parameters to the URL of the link (query-string). -Manolo On Sun, Apr 11, 2010 at 3:40 PM, daaSdemahoM wrote: > Thanks! it works great! > But i need to send a string to the servlet over this iframe. > it s possible to pass a string in any attribute from this iframe? > > please, how can i read the sended value?? > > -- > You received this message because you are subscribed to the Google Groups > "Google Web Toolkit" group. > To post to this group, send email to google-web-tool...@googlegroups.com. > To unsubscribe from this group, send email to > google-web-toolkit+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/google-web-toolkit?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: File Download in GWT
Thanks! it works great! But i need to send a string to the servlet over this iframe. it s possible to pass a string in any attribute from this iframe? please, how can i read the sended value?? -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: File Download in GWT
Yes, you cannot do it with ajax, you must use a link with the src pointing to a hidden iframe or a new window. Take a look to how it is done in Hupa (Apache-James webmail) - Server side (line 100): http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/servlet/DownloadAttachmentServlet.java?view=markup - Client side code (line 142) http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/IMAPMessageView.java?view=markup - Html page http://svn.apache.org/viewvc/james/hupa/trunk/client/war/Hupa.html?view=markup Cheers Manolo On Sun, Apr 11, 2010 at 12:02 PM, Thomas Broyer wrote: > > > On Apr 10, 5:02 pm, daaSdemahoM wrote: >> 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 can't trigger a download with RequestBuilder (or anything based on > XMLHttpRequest), you have to use a link (Anchor widget) or form > (FormPanel widget). > > -- > You received this message because you are subscribed to the Google Groups > "Google Web Toolkit" group. > To post to this group, send email to google-web-tool...@googlegroups.com. > To unsubscribe from this group, send email to > google-web-toolkit+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/google-web-toolkit?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: File Download in GWT
On Apr 10, 5:02 pm, daaSdemahoM wrote: > 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 can't trigger a download with RequestBuilder (or anything based on XMLHttpRequest), you have to use a link (Anchor widget) or form (FormPanel widget). -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
File Download in GWT
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 google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.