I had a previous program which is working fine so I just copied the chunk of code and paste it on the new program which I am building. Basically my program will generate a report using JExcel API and then I will try to display it on the web so that user can Open/Save/Cancel it (the normal IE notification window). Furthermore, there is no error message on the tomcat log.
[ November 27, 2007: Message edited by: Maruli Lee ] [ November 27, 2007: Message edited by: Bear Bibeault ]
Of course it won't - JSP has automagically already gotten the output stream for character output - thats what JSP do. You are undoubtedly getting a java.io.IllegalStateException thrown at that point. See the JavaDocs.
As has been mentioned, JSPs are designed for output of text. Sending a binary file via JSP is tricky for a number of reasons.
I would recommend you read Bear's excellent article on this subject: The Secret Life of JavaServer Pages where he answers the question "Why does everyone tell me to use a servlet to send binary data to the browser? I wanna use a JSP!"
You've written it all in java code anyway - it SHOULD be a servlet.