according to the J2EE design patterns, JSP's should only be used to produce text output. Any binary output (such as Excel files) should be produced with servlets--otherwise, the JSP becomes one big scriptlet (like this one).If you still want to do this with a JSP, you might want to take out your try ... catch block since you're not doing anything with it. Doing so will allow you to let the servlet container handle the errors (i.e. specify error pages in the web application deployment descriptor). Either that, or at least put the close() and flush()calls in it since they can throw IOExceptions, too. :)Finally, you should never close the servlet's output stream. Leave that up to the servlet container.