Thanks for your help, I'm using Tomcat 4.0.3, the HTTP server is IIS. Following the generated log entries when downloading a file:
---> 1. Request for download [23.05.2002 11:18:35] - INFO: sims.servlet.filter.EventFilter.doFilter-> Start Request: Thu May 23 11:18:35 CEST 2002 for /oraweb/sims/control?action=dir_browser_download&user=1&area=download&id=131 E0A96B309778C3D4881D52693171A&file=CH%20Switzerland_COU_Input.xls [23.05.2002 11:18:35] - INFO: Controller start: User=rbad /oraweb/sims/control?action=dir_browser_download&user=1&area=download&id=131 E0A96B309778C3D4881D52693171A&file=CH%20Switzerland_COU_Input.xls [session=131E0A96B309778C3D4881D52693171A] [23.05.2002 11:18:35] - INFO: Controller end: User=rbad /oraweb/sims/control?action=dir_browser_download&user=1&area=download&id=131 E0A96B309778C3D4881D52693171A&file=CH%20Switzerland_COU_Input.xls [session=131E0A96B309778C3D4881D52693171A] [23.05.2002 11:18:35] - INFO: sims.servlet.filter.EventFilter.doFilter-> Response delivered after: 251ms ---> Request (don't have any idea for what) [23.05.2002 11:18:37] - INFO: sims.servlet.filter.EventFilter.doFilter-> Start Request: Thu May 23 11:18:37 CEST 2002 for /oraweb/sims [23.05.2002 11:18:37] - DEBUG: sims.servlet.filter.EventFilter.doFilter-> No form in request [23.05.2002 11:18:37] - INFO: sims.servlet.filter.EventFilter.doFilter-> Response delivered after: 10ms ---> 2. Request for download [23.05.2002 11:18:39] - INFO: sims.servlet.filter.EventFilter.doFilter-> Start Request: Thu May 23 11:18:39 CEST 2002 for /oraweb/sims/control?action=dir_browser_download&user=1&area=download&id=131 E0A96B309778C3D4881D52693171A&file=CH%20Switzerland_COU_Input.xls [23.05.2002 11:18:39] - INFO: com.inetsystems.iframe.smi.listener.sessionCreated-> Session 97412DCD3767F904680EDFE212748AE3 created. [23.05.2002 11:18:39] - DEBUG: SMIController.initSession-> New SMI in session 97412DCD3767F904680EDFE212748AE3 created. [23.05.2002 11:18:39] - INFO: Controller start: /oraweb/sims/control?action=dir_browser_download&user=1&area=download&id=131 E0A96B309778C3D4881D52693171A&file=CH%20Switzerland_COU_Input.xls [session=97412DCD3767F904680EDFE212748AE3] [23.05.2002 11:18:39] - INFO: Controller end: /oraweb/sims/control?action=dir_browser_download&user=1&area=download&id=131 E0A96B309778C3D4881D52693171A&file=CH%20Switzerland_COU_Input.xls [session=97412DCD3767F904680EDFE212748AE3] [23.05.2002 11:18:39] - DEBUG: sims.servlet.filter.EventFilter.doFilter-> No form in request [23.05.2002 11:18:39] - INFO: sims.servlet.filter.EventFilter.doFilter-> Response delivered after: 10ms The above log is from my development machine and only 1 person is connected to the application. In the URL i put the session id to retrieve session information for the download request done in a new session. In the 1. download request the session id parameter contains the same value as the current session. For the 2. download request a new session was created. Don't know what caused the request '/oraweb/sims' after the 1. download request. When connecting directly to Tomcat, I don't get an additional sessions - any way i get 2 additional requests. But no additional sessions are created. [23.05.2002 11:37:13] - INFO: Controller start: User=rbad /oraweb/sims/control?action=dir_browser_download&user=1&area=download&id131E 0A96B309778C3D4881D52693171A&file=CH%20Switzerland_COU_Input.xls [session=131E0A96B309778C3D4881D52693171A] [23.05.2002 11:37:13] - INFO: Controller end: User=rbad /oraweb/sims/control?action=dir_browser_download&user=1&area=download&id=131 E0A96B309778C3D4881D52693171A&file=CH%20Switzerland_COU_Input.xls [session=131E0A96B309778C3D4881D52693171A] [23.05.2002 11:37:13] - DEBUG: sims.servlet.filter.EventFilter.doFilter-> No form in request [23.05.2002 11:37:13] - INFO: sims.servlet.filter.EventFilter.doFilter-> Response delivered after: 10ms [23.05.2002 11:37:13] - INFO: sims.servlet.filter.EventFilter.doFilter-> Start Request: Thu May 23 11:37:13 CEST 2002 for /oraweb/sims?null [23.05.2002 11:37:13] - DEBUG: sims.servlet.filter.EventFilter.doFilter-> No form in request [23.05.2002 11:37:13] - INFO: sims.servlet.filter.EventFilter.doFilter-> Response delivered after: 0ms [23.05.2002 11:37:13] - INFO: sims.servlet.filter.EventFilter.doFilter-> Start Request: Thu May 23 11:37:13 CEST 2002 for /oraweb/sims/control?action=dir_browser_download&user=1&area=download&id=131 E0A96B309778C3D4881D52693171A&file=CH%20Switzerland_COU_Input.xls [23.05.2002 11:37:13] - DEBUG: sims.servlet.filter.EventFilter.doFilter-> No form in request [23.05.2002 11:37:13] - INFO: sims.servlet.filter.EventFilter.doFilter-> Response delivered after: 10ms >>Another thought: Are you calling flush() after you finish serving the binary Excel file? No, should this be done ? For me it looks like Excel is launched in a new IE instance and therefore a new session will be created. Reto -----Urspr�ngliche Nachricht----- Von: Michael Zalewski [mailto:[EMAIL PROTECTED]] Gesendet: Donnerstag, 23. Mai 2002 03:17 An: POI Users List Betreff: RE: POI and JSP HttpResponse.encodeURL(aURL). That's what I meant by 'send it through'. Actually, I probably should have said HttpServletResponse.encodeURL(). But you get the idea. This technique works for me. How are you logging the start of a new session? What environment are you using (It works for me under both JRun 3.1 and IBM Websphere 3.5. Not sure about TomCat, but I see no reason why it should behave differently). What web server? What OS on the web server? How many processors on the web server? You may be facing a multiple threading issue. Perhaps a new session is being created for the second download because the first session has not finished sending the header yet. As an experiment, try to put a sleep() in somewhere before you call HttpServletRequest.getSession(). Probably don't need to sleep for any more than about 1 second. This should give the first download from IE enough time to recognize that the session is gone. Another experiment would be to log when the servlet calls getSession(), and again when the servlet finishes. You might see something like this: getSession() 1 getSession() 2 finish() 1 finish() 2 But actually, even if you don't see the above, I bet that kind of interleaving is what is happening. I believe this happens because of the way IE downloads things. IE will close the download connection any time its logic thinks that that would be convenient. For example, to determine if a cached version of an image file is expired, IE will always download the entire image file with HTTP GET. It almost never uses HEAD. If IE has a version of the image file in its cache, and if in processing the GET, IE determines that the cached copy is up to date, IE simply closes the connection on the client end. The poor web server is still trying to send the rest of the image file. I bet that's what is happening with your Excel Download. 1. IE does a GET to determine what kind of file it is. This GET includes a cookie which identifies the web session. 2. Servlet (or JSP) gets the request with the cookie, and sends the Excel file. 3. Before the servlet has finished sending the file, IE determines that it really is an Excel file, and closes the connection. 4. IE launches Excel, and tells Excel to download the URL. 5. Excel opens the URL connection. But Excel has no idea about transient cookies, so if you don't encodeURL, there is no chance that the Excel request will match the session. 6. If your client machine is fast enough, or perhaps if your HTTP server is not IIS, the servlet which was attempting to send the entire Excel file to IE may not have finished the request yet. If the first request has not completed, I am not sure what happens when a new request for the same session ID is processed. Actually, if your web server has multiple processors, I am pretty sure that you could in fact create two sessions for the same session id like this. BTW, all of the above is only a radical conjecture, mixed in with a little bit of educated guesswork. Another thought: Are you calling flush() after you finish serving the binary Excel file? Calling flush() on a broken pipe should throw an exception, which would allow the first request to terminate. Yet Another thought: Try implementing SingleThreadModel. That will tell you if two requests are vying for the same session. -----Original Message----- From: Reto Badertscher [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 22, 2002 11:10 AM To: POI Users List Subject: AW: POI and JSP >You cannot prevent the double-download (I don't think). But you can >make the second download part of the session. Just send the URL through >HttpSession.encodeUrl(). Shouldn't it be HttpResponse.encodeURL(aUrl) ? I tried it, but it didn't help. When i look in my logs then i see that the second download is using a new session. Reto -----Urspr�ngliche Nachricht----- Von: Michael Zalewski [mailto:[EMAIL PROTECTED]] Gesendet: Mittwoch, 22. Mai 2002 15:07 An: POI Users List Betreff: RE: POI and JSP The double-download is unavoidable AFAIK. The reason is that IE does not believe the server header for mime type. It double checks by downloading the file header. I think it only downloads the front part of the file. Maybe only the first 512 bytes. According to a Microsoft article I read, this is a feature. It allows IE to launch Excel (or Word, PowerPoint, or any other Office tool) even on ISPs that do not support the custom mime types, which would be the standard way of telling a browser what type of file is being downloaded. The second download would be from Excel. Excel would not know about the cookies you are probably using to identify the user session, so it looks like a new session in the log. You cannot prevent the double-download (I don't think). But you can make the second download part of the session. Just send the URL through HttpSession.encodeUrl(). -----Original Message----- From: Reto Badertscher [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 22, 2002 6:05 AM To: POI Users List Subject: AW: POI and JSP Hello, i do it similar as described. Additionally I add a header as follows: response().addHeader("Content-disposition", "attachement; filename=" + file.getName()); The file will be opened by IE, but in a new session. When looking at my logs i have 2 requests for a download: 1. From the user who requested the file and has already a session and is identified 2. The same request in a new session The URL:/server/app/control?action=dir_browser_download&user=1&area=download&fil e=test.xls Does anyone knows why this happens and how to prevent it Thanks Reto -----Urspr�ngliche Nachricht----- Von: Danny Angus [mailto:[EMAIL PROTECTED]] Gesendet: Mittwoch, 22. Mai 2002 10:36 An: POI Users List; Ferruccio Spagna Betreff: RE: POI and JSP > The only problem is now that IExplorer > doesn't open Excel automatically (Netscape does), or can I do > something for > this? I tried to stream to the client an xls from a servlet that specifies > the content-type without having better result. 1/ set content-type to "application/x-excel" 2/ make your link end with .xls EG: http://mysite.com/context/servlet/org.apache.test/x.xls?param=value This works, M$IE recognises "x.xls" as an excel file, and tomcat will call org.apache.test.doGet(), and pass in the parameters correctly, to generate it. M$IE opens Excel in a COM in-browser process. You can also use the URL in the File->open dialogue of Excel to open the generated xls file directly without using IE. d. -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
