Does anyone tried to have a JSP page saved to excel? Im using JBoss 3.2.2. I have a JSP page and I want to save it to excel. Im using --
<%@ page contentType="application/vnd.ms-excel" %> --
but still it won't work. Any ideas?
ContentType is correct, but there are some other things that you have to take care, such as
Buffer Issue. JSP is template-based and it outputs every it doesn't recoginized (such as whitespaces). So, you have to clear buffer at the end with <%out.clear();%>. Of course, it means you have to send output by yourself (in one of your custom tag).
Also ensure that you set the content type before any output has been generated by the JSP. That is; there cannot be any out.print() or out.println() statements before the response.setContentType() statement - the JSP tag should translate to this setContentType method call. Check the generated Java source file to ensure that you have dealt with the situation - some people format the JSP code so that everything looks well-spaced but introduce characters to the actual output (HTTP) stream. Once characters are injected into the stream, you generally cannot change the content type of the stream.
We often do the following for Excel-type output:
Hope that helps.
M sori it took a while for me to check and test your ideas. I've been out of office for almost a month, I had a short vacation and after a training. Anyway, can you give me (if possible) a sample code. Should I issue clear buffer every end of the line? How would I assure that the content type of my generated java source file has been set successfully. I tried some of your scripts, still I wasn't to get my desired result. Are there any necessary configurations neede at JBoss for this matter?