Re: Problems downloading files. How to identify the CANCEL butto n?
siom...@portosdobrasil.gov.br wrote: Andre came up with a good reason and here is mine: I work for the brazilian government that wants to keep track of people who download certain specific files. It also wants to send emails to the ones that at least started the download procces of these files. So, for this reason, there is no interest at all to send emails for those that canceled the download process. I am looking forward for a solution because the way my code is now is wrong. It is logging everybody no matter which button they pressed (open, save or cancel). Once more, any suggestion is more than welcome. Siomara, What you want, is impossible from the server side, because the server by itself will never know. Your code is not wrong, you are just limited by the reality of how it works. What maybe is missing in your understanding, is that those buttons in the browser (run, save, cancel,..) /do not send anything/ to the server. Their action is purely local to the browser. When a user presses the cancel button, that just tells the browser to stop reading what is coming from the network on that connection, and close the connection. But by that time, because of all the buffering in-between, it is possible that the server is already done sending everything, since 1 minute. Please re-read the answers you have already received. Your question has already been answered, and there are no more suggestions that anyone can make. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Problems downloading files. How to identify the CANCEL butto n?
What is the business requirement that forces you to log such information? What is the cost of a false positive? Some time ago I experimented with AccessLogValve, trying to download some large file, to see how it logs aborted downloads. I used Firefox and pressed cancel as soon as Save As dialog was displayed. The result is that the log showed about 40-50 Mb of transfered data by that time (the whole file was about 70 Mb), thus the browser was caching the result while displaying the dialog. Also, are you going to support resuming aborted downloads? Are you dealing with download accelerators (that try to download the same file in several pieces). You will know which byte ranges were requested, but the size of each piece will be less than the whole file. 2009/7/8 siom...@portosdobrasil.gov.br: The buttons I see [OPEN], [SAVE] and [CANCEL] are not created and controlled by me. They belong to the download manager window that comes automatically with a certain command. The problem I noticed is that by the time this download manager window shows up the entire code on the servlet has been already executed. The messages bellow that I included are displayed before any click on any of those buttons. here 1 here 2 here 3 here 4 here 5 here 6 Any help is welcome. I am looking so hard for a solution but I am not finding anything on the web. Siomara -Mensagem original- De: Martin Gainty [mailto:mgai...@hotmail.com] Enviada em: terça-feira, 7 de julho de 2009 19:51 Para: Tomcat Users List Assunto: RE: Problems downloading files. How to identify the CANCEL button? at least 2 ways to determine the button selected 1)set a boolean property which is enabled on or off based on executed button class MyAction extends ActionSupport { private boolean submit; private boolean clear; public void setSubmit(boolean submit) { this.submit = submit; } public void setClear(boolean clear) { this.clear = clear; } public String execute() { if (submit) { doSubmit(); return submitResult; } if (clear) { doClear(); return clearResult; } return super.execute(); } }2)check the name of the button as indicated here class MyAction extends ActionSupport { private String buttonName; public void setButtonName(String buttonName) { this.buttonName = buttonName; } public String execute() { if (Submit.equals(buttonName)) { doSubmit(); return submitResult; } if (Clear.equals(buttonName)) { doClear(); return clearResult; } return super.execute(); } }http://cwiki.apache.org/WW/multiple-submit-buttons.html many other solutions are available from devs Martin __ Verzicht und Vertraulichkeitanmerkung Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. From: siom...@portosdobrasil.gov.br To: users@tomcat.apache.org Subject: Problems downloading files. How to identify the CANCEL button? Date: Tue, 7 Jul 2009 15:09:05 -0300 Dear all, I need to log some information only after a user downloads or opens a file. I am using a servlet for that and the download part works fine. However I need to identify which button was clicked because in case the user clicks [CANCEL] I am not supposed to register any information. I put lots of messages on the code to understand how it works and even if I click [CANCEL] the messages will be printed showing that all commands will be executed no matter which button was clicked. Can someone help me to identify which button was clicked? Thanks Siomara === package servlets.comum; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; /** * Definition of class DownloadFile. */ public class DownloadFile extends HttpServlet { private String original_filename = MYFILE.txt; private String filename=C:\\ABC.txt; /** * Processes requests for both HTTP GET and POST methods. * @param request servlet request * @param response servlet response */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { File f = new File(filename); int length = 0; ServletOutputStream op = response.getOutputStream(); ServletContext context = getServletConfig().getServletContext(); String mimetype =
Re: Problems downloading files. How to identify the CANCEL butto n?
Konstantin Kolinko wrote: What is the business requirement that forces you to log such information? What is the cost of a false positive? A usual example is when the customer is paying for some downloaded document. At the server side, you would want an absolute, no-complaints-possible, trace that the download did occur succesfully. Something you can wiggle under the customer's nose when they complain about the bill. All the more reason to have some active component at the client side, acknowledging the download back to the server, with some unique timestamp, id, etc.. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: Problems downloading files. How to identify the CANCEL butto n?
Andre came up with a good reason and here is mine: I work for the brazilian government that wants to keep track of people who download certain specific files. It also wants to send emails to the ones that at least started the download procces of these files. So, for this reason, there is no interest at all to send emails for those that canceled the download process. I am looking forward for a solution because the way my code is now is wrong. It is logging everybody no matter which button they pressed (open, save or cancel). Once more, any suggestion is more than welcome. Siomara -Mensagem original- De: André Warnier Para: Tomcat Users List Enviada em: 11/07/2009 06:24 Assunto: Re: Problems downloading files. How to identify the CANCEL butto n? Konstantin Kolinko wrote: What is the business requirement that forces you to log such information? What is the cost of a false positive? A usual example is when the customer is paying for some downloaded document. At the server side, you would want an absolute, no-complaints-possible, trace that the download did occur succesfully. Something you can wiggle under the customer's nose when they complain about the bill. All the more reason to have some active component at the client side, acknowledging the download back to the server, with some unique timestamp, id, etc.. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: RES: Problems downloading files. How to identify the CANCEL butto n?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Siomara, On 7/8/2009 10:36 AM, siom...@portosdobrasil.gov.br wrote: The buttons I see [OPEN], [SAVE] and [CANCEL] are not created and controlled by me. They belong to the download manager window that comes automatically with a certain command. The problem I noticed is that by the time this download manager window shows up the entire code on the servlet has been already executed. As Pid pointed out, you probably need a file of sufficient size in order to test this properly. If you're testing on a local network, I would make sure you have 100MiB or more in reserve to test this out. Any help is welcome. I am looking so hard for a solution but I am not finding anything on the web. Re-read Andre's response: there will be many situations where you simply cannot detect the CANCEL button (what you really mean is an aborted download: the CANCEL button is likely to be an MSIE-only thing). - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkpX6voACgkQ9CaO5/Lv0PCQbACeL+Ty1dQiF2IsTAQlPB4uW4uS KGgAnAjJR+/QuQIeSq6prR134prokbNH =r0kj -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: RES: Problems downloading files. How to identify the CANCEL butto n?
yes Op: could you display the jsp ? Martin Gainty __ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. Date: Fri, 10 Jul 2009 21:29:30 -0400 From: ch...@christopherschultz.net To: users@tomcat.apache.org Subject: Re: RES: Problems downloading files. How to identify the CANCEL butto n? -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Siomara, On 7/8/2009 10:36 AM, siom...@portosdobrasil.gov.br wrote: The buttons I see [OPEN], [SAVE] and [CANCEL] are not created and controlled by me. They belong to the download manager window that comes automatically with a certain command. The problem I noticed is that by the time this download manager window shows up the entire code on the servlet has been already executed. As Pid pointed out, you probably need a file of sufficient size in order to test this properly. If you're testing on a local network, I would make sure you have 100MiB or more in reserve to test this out. Any help is welcome. I am looking so hard for a solution but I am not finding anything on the web. Re-read Andre's response: there will be many situations where you simply cannot detect the CANCEL button (what you really mean is an aborted download: the CANCEL button is likely to be an MSIE-only thing). - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkpX6voACgkQ9CaO5/Lv0PCQbACeL+Ty1dQiF2IsTAQlPB4uW4uS KGgAnAjJR+/QuQIeSq6prR134prokbNH =r0kj -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org _ Windows Live™: Keep your life in sync. http://windowslive.com/explore?ocid=TXT_TAGLM_WL_BR_life_in_synch_062009
RES: Problems downloading files. How to identify the CANCEL butto n?
The buttons I see [OPEN], [SAVE] and [CANCEL] are not created and controlled by me. They belong to the download manager window that comes automatically with a certain command. The problem I noticed is that by the time this download manager window shows up the entire code on the servlet has been already executed. The messages bellow that I included are displayed before any click on any of those buttons. here 1 here 2 here 3 here 4 here 5 here 6 Any help is welcome. I am looking so hard for a solution but I am not finding anything on the web. Siomara -Mensagem original- De: Martin Gainty [mailto:mgai...@hotmail.com] Enviada em: terça-feira, 7 de julho de 2009 19:51 Para: Tomcat Users List Assunto: RE: Problems downloading files. How to identify the CANCEL button? at least 2 ways to determine the button selected 1)set a boolean property which is enabled on or off based on executed button class MyAction extends ActionSupport { private boolean submit; private boolean clear; public void setSubmit(boolean submit) { this.submit = submit; } public void setClear(boolean clear) { this.clear = clear; } public String execute() { if (submit) { doSubmit(); return submitResult; } if (clear) { doClear(); return clearResult; } return super.execute(); } }2)check the name of the button as indicated here class MyAction extends ActionSupport { private String buttonName; public void setButtonName(String buttonName) { this.buttonName = buttonName; } public String execute() { if (Submit.equals(buttonName)) { doSubmit(); return submitResult; } if (Clear.equals(buttonName)) { doClear(); return clearResult; } return super.execute(); } }http://cwiki.apache.org/WW/multiple-submit-buttons.html many other solutions are available from devs Martin __ Verzicht und Vertraulichkeitanmerkung Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. From: siom...@portosdobrasil.gov.br To: users@tomcat.apache.org Subject: Problems downloading files. How to identify the CANCEL button? Date: Tue, 7 Jul 2009 15:09:05 -0300 Dear all, I need to log some information only after a user downloads or opens a file. I am using a servlet for that and the download part works fine. However I need to identify which button was clicked because in case the user clicks [CANCEL] I am not supposed to register any information. I put lots of messages on the code to understand how it works and even if I click [CANCEL] the messages will be printed showing that all commands will be executed no matter which button was clicked. Can someone help me to identify which button was clicked? Thanks Siomara === package servlets.comum; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; /** * Definition of class DownloadFile. */ public class DownloadFile extends HttpServlet { private String original_filename = MYFILE.txt; private String filename=C:\\ABC.txt; /** * Processes requests for both HTTP GET and POST methods. * @param request servlet request * @param response servlet response */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Filef= new File(filename); int length = 0; ServletOutputStream op = response.getOutputStream(); ServletContext context = getServletConfig().getServletContext(); String mimetype = context.getMimeType( filename ); System.out.println(here 1); // Set the response and go! response.setContentType( (mimetype != null) ? mimetype : application/octet-stream ); response.setContentLength( (int)f.length() ); response.setHeader( Content-Disposition, attachment; filename=\ + original_filename + \ ); System.out.println(here 2); // Stream to the requester. byte[] bbuf = new byte[filename.length()]; DataInputStream in = new DataInputStream(new FileInputStream(f)); while ((in != null) ((length = in.read(bbuf)) != -1)) { op.write(bbuf,0,length); } System.out.println(here 3); in.close(); System.out.println(here 4); op.flush();