>From the FAQ: 7. I'm trying to stream an XLS file from a servlet and I'm having some trouble. What's the problem?
The problem usually manifests itself as the junk characters being shown on screen. The problem persists even though you have set the correct mime type. The short answer is, don't depend on IE to display a binary file type properly if you stream it via a servlet. Every minor version of IE has different bugs on this issue. The problem in most versions of IE is that it does not use the mime type on the HTTP response to determine the file type; rather it uses the file extension on the request. Thus you might want to add a .xls to your request string. For example http://yourserver.com/myServelet.xls?param1=xx. This is easily accomplished through URL mapping in any servlet container. Sometimes a request like http://yourserver.com/myServelet?param1=xx&dummy=file.xls is also known to work. To guarantee opening the file properly in Excel from IE, write out your file to a temporary file under your web root from your servelet. Then send an http response to the browser to do a client side redirection to your temp file. (Note that using a server side redirect using RequestDispatcher will not be effective in this case) Note also that when you request a document that is opened with an external handler, IE sometimes makes two requests to the webserver. So if your generating process is heavy, it makes sense to write out to a temporary file, so that multiple requests happen for a static file. None of this is particular to Excel. The same problem arises when you try to generate any binary file dynamically to an IE client. For example, if you generate pdf files using FOP, you will come across many of the same issues. ciao Bodo > -----Urspr�ngliche Nachricht----- > Von: Dasmeet S Ahluwalia [mailto:[EMAIL PROTECTED] > Gesendet: Donnerstag, 4. M�rz 2004 05:43 > An: [EMAIL PROTECTED] > Betreff: Issue with POI - HSSF > > > Hi, > > I am facing a problem with HSSFWorkbook... > > Actually i am using this POI for handling Export functionality in JSP > reports. > I have a link "Export" clicking which i get the data and export it to > excel file. For this I am using ServletOutputStream. > > the pseudocode is.... > res.setContentType("application/octet-stream"); > res.setHeader("Content-Disposition","attachment; > filename=\"abc.xls\""); > ServletOutputStream sOutStream = res.getOutputStream(); > . > . > . > . > HSSFWorkbook wbExlFile = new HSSFWorkbook(); > wbExlFile.write(sOutStream); > > Everything works fine....the problem lies in display of "File > Download > Popup". Somehow it is displayed twice. > Can someone help me to figure out why this is happening? > > Thanks in advance. > > Regards, > Dasmeet Singh. > >
smime.p7s
Description: S/MIME cryptographic signature
