Rob Spoor wrote:You shouldn't use JSP files to display any binary file, including Excel files. Any whitespace between tags (like at the top, between import directives) can already be added to the output. That will cause corruption of binary files. Instead, use a servlet to display the binary file.
Repeated for emphasis.
JSPs are great for text files, including XML, JSON and YAML. For binary files, they are not. For one thing, the response buffers have been pre-loaded with headers related to the idea that text is coming out. The
response.reset() tells the server to undo that work.
So in addition to being ill-suited for binary output, you're being less efficient by making it do and undo useless work. Servlets don't have that problem.