This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
You shouldn't use JSP files for binary data. The problem is that any line break outside tags will be included in the response. This includes line breaks between import tags, etc. When such a line break is included in the response, this is written to the writer (as returned by getWriter()). As a result you can't call getOutputStream() anymore.
There are three solutions:
1) Simply don't include any line breaks. Let each tag follow the next tag. For instance, not but instead Each and any line break should be removed.
2) Not sure about this one, but perhaps you can turn on output buffering and clear the buffer before you start writing the Excel report.
3) Definitely the preferred way - use a Servlet instead of a JSP file. With servlets you have full control over what's printed out. If you don't call getWriter() explicitly then it's not called at all.