Sin-Kang(강신) +82-10-6638-7878 +44-78555-49312
On Mon, Aug 24, 2009 at 3:29 PM, vijjj <[email protected]> wrote: > > > Any pointers to solve this issue would be appreciated. > > If my above post found to be cumbersome, here is what I am trying to > do. > > Create an Excel sheet from the server side and display/save as in the > the browser. I understand there are some restriction in sending the > stream through the GWT rpc mechanism, hence I have used a plain > Servlet. > > My problem is with the ServletOutputStream. Whatever the approach I > take, it always turned out to be "Closed". > > I am new to GWT and do not have much experience in file download. > > Even though the server side log displays ServletOutputStream Closed > error, the browser displays "GET" is not allowed or "POST" is not > allowed (I tried both methods). Yes, I do have doGet and doPost method > in the servlet. > > I think there is timeout issues related to appengine. > I can not recall exact how long but I remember It is not enough to do something. So In my case, I've implemented using another servlet located in different server. > > > > On Aug 21, 2:24 pm, vijjj <[email protected]> wrote: > > I have a simple servlet in my GWT application that creates a Excel > > sheet (Using JXL library) and writes the outputstream to the response. > > > > But this ends up in the following exception. > > > > The result is same when I use Window.open/RequestBuilder and even when > > I do form submit. > > > > I am using GWT/Apps Engine plugin for Eclipse 3.5. > > > > Appreciate any help towards this. > > > > java.io.IOException: Closed > > at org.mortbay.jetty.AbstractGenerator$Output.write > > (AbstractGenerator.java:595) > > at > com.test.server.ReportServlet.generateXLS(ReportServlet.java:147) > > at com.test.server.ReportServlet.doPost(ReportServlet.java:47) > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:713) > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:806) > > at > org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java: > > 487) > > > > Here is my come > > > > public class ReportServlet extends HttpServlet { > > > > public void generateXLS(HttpServletRequest req, HttpServletResponse > > response) throws ServletException, IOException { > > ByteArrayOutputStream baos = new ByteArrayOutputStream(); > > WritableWorkbook workbook = Workbook.createWorkbook(baos); > > WritableSheet sheet = workbook.createSheet("Leave > Report", 0); > > Label idLabel = new Label(0, 0, "ID"); > > sheet.addCell(idLabel); > > > > response.setContentType("application/vnd.ms-excel"); > > response.setHeader("Expires", "0"); > > response.setHeader("Cache-Control", "no-cache"); > > response.setHeader("Pragma", "public"); > > String fileName = "LeaveReport.xls"; > > > response.setHeader("Content-Disposition","attachment; filename=\"" > > + fileName +"\""); > > //response.setCharacterEncoding("utf-8"); > > //response.setHeader("Transfer-Encoding", "Chunked"); > > > > response.setContentLength(baos.size()); > > //response.setBufferSize(baos.size()); > > //response.flushBuffer(); > > ServletOutputStream out = > response.getOutputStream(); > > > > //DataOutputStream out = new DataOutputStream > > (response.getOutputStream()); > > //baos.writeTo(out); > > > > byte[] outs = baos.toByteArray(); > > for (int i = 0; i < outs.length; i++) { > > System.out.println(i); > > out.write(outs[i]); > > } > > > > out.flush(); > > out.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 -~----------~----~----~----~------~----~------~--~---
