javascript and servlets.
I have a form with multiple input name=file0 elements. The names are generated and range file0..n I'm trying (and failing) to retrieve the value of the input fields. String f =; f = request.getParameter(file0); works fine; The remainder appear inaccessible. In the docs ...webapps/tomcat-docs/servletapi/index.html I'm warned: You should only use this method when you are sure the parameter has only one value. If the parameter might have more than one value, use getParameterValues(java.lang.String). However, since each entry within the form has a variant name value, what parameter should I pass to the getParameterValues method to retrieve the multiple values? tc 5.0.27 in use. Regards DaveP. snip here * -- DISCLAIMER: NOTICE: The information contained in this email and any attachments is confidential and may be privileged. If you are not the intended recipient you should not use, disclose, distribute or copy any of the content of it or of any attachment; you are requested to notify the sender immediately of your receipt of the email and then to delete it and any attachments from your system. RNIB endeavours to ensure that emails and any attachments generated by its staff are free from viruses or other contaminants. However, it cannot accept any responsibility for any such which are transmitted. We therefore recommend you scan all attachments. Please note that the statements and views expressed in this email and any attachments are those of the author and do not necessarily represent those of RNIB. RNIB Registered Charity Number: 226227 Website: http://www.rnib.org.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: javascript and servlets.
String[] f = request.getParameterValues(file0); f[0] .. f[f.length - 1] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, September 03, 2004 9:16 AM To: [EMAIL PROTECTED] Subject: javascript and servlets. String f =; f = request.getParameter(file0); works fine; The remainder appear inaccessible. In the docs ...webapps/tomcat-docs/servletapi/index.html
RE: javascript and servlets.
use getParameterNames public java.util.Enumeration getParameterNames() to get the name of all input fields and then getParameter to get the value(s) oh each parameter Laurent -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Envoy : vendredi 3 septembre 2004 09:16 : [EMAIL PROTECTED] Objet : javascript and servlets. I have a form with multiple input name=file0 elements. The names are generated and range file0..n I'm trying (and failing) to retrieve the value of the input fields. String f =; f = request.getParameter(file0); works fine; The remainder appear inaccessible. In the docs ...webapps/tomcat-docs/servletapi/index.html I'm warned: You should only use this method when you are sure the parameter has only one value. If the parameter might have more than one value, use getParameterValues(java.lang.String). However, since each entry within the form has a variant name value, what parameter should I pass to the getParameterValues method to retrieve the multiple values? tc 5.0.27 in use. Regards DaveP. snip here * -- DISCLAIMER: NOTICE: The information contained in this email and any attachments is confidential and may be privileged. If you are not the intended recipient you should not use, disclose, distribute or copy any of the content of it or of any attachment; you are requested to notify the sender immediately of your receipt of the email and then to delete it and any attachments from your system. RNIB endeavours to ensure that emails and any attachments generated by its staff are free from viruses or other contaminants. However, it cannot accept any responsibility for any such which are transmitted. We therefore recommend you scan all attachments. Please note that the statements and views expressed in this email and any attachments are those of the author and do not necessarily represent those of RNIB. RNIB Registered Charity Number: 226227 Website: http://www.rnib.org.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: javascript and servlets.
-Original Message- From: Marot Laurent [mailto:[EMAIL PROTECTED] Sent: 03 September 2004 08:33 To: Tomcat Users List Subject: RE: javascript and servlets. use getParameterNames public java.util.Enumeration getParameterNames() to get the name of all input fields and then getParameter to get the value(s) oh each parameter Thanks Laurent: java.util.Enumeration enum = request.getParameterNames(); while (enum.hasMoreElements()){ String s = (String)enum.nextElement(); out.println(p+s+/p); } Produces no output? Implies that hasMoreElements() is false? Ralph suggested String[] f = request.getParameterValues(file0); f[0] .. f[f.length - 1] but I can't see how that will access the entry with name file1, file2 etc? Perhaps all the entries should be named the same (which seems illogical). regards DaveP ** snip here ** -- DISCLAIMER: NOTICE: The information contained in this email and any attachments is confidential and may be privileged. If you are not the intended recipient you should not use, disclose, distribute or copy any of the content of it or of any attachment; you are requested to notify the sender immediately of your receipt of the email and then to delete it and any attachments from your system. RNIB endeavours to ensure that emails and any attachments generated by its staff are free from viruses or other contaminants. However, it cannot accept any responsibility for any such which are transmitted. We therefore recommend you scan all attachments. Please note that the statements and views expressed in this email and any attachments are those of the author and do not necessarily represent those of RNIB. RNIB Registered Charity Number: 226227 Website: http://www.rnib.org.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[OT] RE: javascript and servlets.
very surprising ... to ensure you really send parameters, just try to get one of them with usual getParameter(param). but i think it is slighly off-topic -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Envoy : vendredi 3 septembre 2004 09:38 : [EMAIL PROTECTED] Objet : RE: javascript and servlets. -Original Message- From: Marot Laurent [mailto:[EMAIL PROTECTED] Sent: 03 September 2004 08:33 To: Tomcat Users List Subject: RE: javascript and servlets. use getParameterNames public java.util.Enumeration getParameterNames() to get the name of all input fields and then getParameter to get the value(s) oh each parameter Thanks Laurent: java.util.Enumeration enum = request.getParameterNames(); while (enum.hasMoreElements()){ String s = (String)enum.nextElement(); out.println(p+s+/p); } Produces no output? Implies that hasMoreElements() is false? Ralph suggested String[] f = request.getParameterValues(file0); f[0] .. f[f.length - 1] but I can't see how that will access the entry with name file1, file2 etc? Perhaps all the entries should be named the same (which seems illogical). regards DaveP ** snip here ** -- DISCLAIMER: NOTICE: The information contained in this email and any attachments is confidential and may be privileged. If you are not the intended recipient you should not use, disclose, distribute or copy any of the content of it or of any attachment; you are requested to notify the sender immediately of your receipt of the email and then to delete it and any attachments from your system. RNIB endeavours to ensure that emails and any attachments generated by its staff are free from viruses or other contaminants. However, it cannot accept any responsibility for any such which are transmitted. We therefore recommend you scan all attachments. Please note that the statements and views expressed in this email and any attachments are those of the author and do not necessarily represent those of RNIB. RNIB Registered Charity Number: 226227 Website: http://www.rnib.org.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [OT] RE: javascript and servlets.
-Original Message- From: Marot Laurent very surprising ... to ensure you really send parameters, just try to get one of them with usual getParameter(param). Yes, the first entry element value is retrievable easily f = request.getParameter(file0); returns the value no problem. form method=post action=/repository/getit name=form ol id=ULlist li input type=file id=file0 name=file0 input type=button onclick=showUpload(event); value=Upload another file? /li /ol input type=submit value=Submit.../ /form Further input items are added via javascript, to enable multiple file uploads. The name attribute is set in the jscript to file+ iteration value. regards DaveP ** snip here ** -- DISCLAIMER: NOTICE: The information contained in this email and any attachments is confidential and may be privileged. If you are not the intended recipient you should not use, disclose, distribute or copy any of the content of it or of any attachment; you are requested to notify the sender immediately of your receipt of the email and then to delete it and any attachments from your system. RNIB endeavours to ensure that emails and any attachments generated by its staff are free from viruses or other contaminants. However, it cannot accept any responsibility for any such which are transmitted. We therefore recommend you scan all attachments. Please note that the statements and views expressed in this email and any attachments are those of the author and do not necessarily represent those of RNIB. RNIB Registered Charity Number: 226227 Website: http://www.rnib.org.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: javascript and servlets.
Sorry i misread your post, that is the solution to retrieve the values if you have more than one field with the same name. If you have file0 through filen this should work: request.getParameter(file0); .. request.getParameter(filen); if file1 through filen are null against your expectations, I would say something is wrong on the client side. Some recommendations: - change method to get so you can see the fields as query string. - Make shure that all fields are in the same form -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, September 03, 2004 9:38 AM To: [EMAIL PROTECTED] Subject: RE: javascript and servlets. but I can't see how that will access the entry with name file1, file2 etc?
RE: javascript and servlets.
If you have file0 through filen this should work: request.getParameter(file0); .. request.getParameter(filen); if file1 through filen are null against your expectations, I would say something is wrong on the client side. I'm beginning to suspect that too! Some recommendations: - change method to get so you can see the fields as query string. How please? - Make sure that all fields are in the same form I'll check. Thanks. regards DaveP ** snip here ** -- DISCLAIMER: NOTICE: The information contained in this email and any attachments is confidential and may be privileged. If you are not the intended recipient you should not use, disclose, distribute or copy any of the content of it or of any attachment; you are requested to notify the sender immediately of your receipt of the email and then to delete it and any attachments from your system. RNIB endeavours to ensure that emails and any attachments generated by its staff are free from viruses or other contaminants. However, it cannot accept any responsibility for any such which are transmitted. We therefore recommend you scan all attachments. Please note that the statements and views expressed in this email and any attachments are those of the author and do not necessarily represent those of RNIB. RNIB Registered Charity Number: 226227 Website: http://www.rnib.org.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [OT] RE: javascript and servlets.
just put one name.. say myFile. then get it thru String[] myFile = getParamterValues(myFile)... for(int i=0; imyFile.length;i++) { myFile[i]; } regards, aris -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, September 03, 2004 4:37 PM To: [EMAIL PROTECTED] Subject: RE: [OT] RE: javascript and servlets. -Original Message- From: Marot Laurent very surprising ... to ensure you really send parameters, just try to get one of them with usual getParameter(param). Yes, the first entry element value is retrievable easily f = request.getParameter(file0); returns the value no problem. form method=post action=/repository/getit name=form ol id=ULlist li input type=file id=file0 name=file0 input type=button onclick=showUpload(event); value=Upload another file? /li /ol input type=submit value=Submit.../ /form Further input items are added via javascript, to enable multiple file uploads. The name attribute is set in the jscript to file+ iteration value. regards DaveP ** snip here ** -- DISCLAIMER: NOTICE: The information contained in this email and any attachments is confidential and may be privileged. If you are not the intended recipient you should not use, disclose, distribute or copy any of the content of it or of any attachment; you are requested to notify the sender immediately of your receipt of the email and then to delete it and any attachments from your system. RNIB endeavours to ensure that emails and any attachments generated by its staff are free from viruses or other contaminants. However, it cannot accept any responsibility for any such which are transmitted. We therefore recommend you scan all attachments. Please note that the statements and views expressed in this email and any attachments are those of the author and do not necessarily represent those of RNIB. RNIB Registered Charity Number: 226227 Website: http://www.rnib.org.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: javascript and servlets.
form method=get ... /form the query string can be found in the access log. (This might be turned of) From your last post with the source I think that each input tag has it's own form so only one field is submitted. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, September 03, 2004 10:47 AM To: [EMAIL PROTECTED] Subject: RE: javascript and servlets. Some recommendations: - change method to get so you can see the fields as query string. How please? - Make sure that all fields are in the same form I'll check.
RE: javascript and servlets.
-Original Message- From: Ralph Einfeldt form method=get ... /form the query string can be found in the access log. (This might be turned of) How do I enable it please? From your last post with the source I think that each input tag has it's own form so only one field is submitted. I noted that the jscript adds extra input elements within the form, hence there are many, each with a differing name attribute. All within the same form. regards DaveP -- DISCLAIMER: NOTICE: The information contained in this email and any attachments is confidential and may be privileged. If you are not the intended recipient you should not use, disclose, distribute or copy any of the content of it or of any attachment; you are requested to notify the sender immediately of your receipt of the email and then to delete it and any attachments from your system. RNIB endeavours to ensure that emails and any attachments generated by its staff are free from viruses or other contaminants. However, it cannot accept any responsibility for any such which are transmitted. We therefore recommend you scan all attachments. Please note that the statements and views expressed in this email and any attachments are those of the author and do not necessarily represent those of RNIB. RNIB Registered Charity Number: 226227 Website: http://www.rnib.org.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: javascript and servlets.
-Original Message- From: Ralph Einfeldt If you have file0 through filen this should work: request.getParameter(file0); .. request.getParameter(filen); if file1 through filen are null against your expectations, I would say something is wrong on the client side. And so it was Ralph. No idea what, but I'm now iterating through the attribute values happily... except, Theinput type=file id=file0 name=file0 I enter a full path, e.g. c:\dir\dir\file.ext and the retrieved value is file.ext. I'm still missing a bit, but so far so good! Tks for the tips. regards DaveP -- DISCLAIMER: NOTICE: The information contained in this email and any attachments is confidential and may be privileged. If you are not the intended recipient you should not use, disclose, distribute or copy any of the content of it or of any attachment; you are requested to notify the sender immediately of your receipt of the email and then to delete it and any attachments from your system. RNIB endeavours to ensure that emails and any attachments generated by its staff are free from viruses or other contaminants. However, it cannot accept any responsibility for any such which are transmitted. We therefore recommend you scan all attachments. Please note that the statements and views expressed in this email and any attachments are those of the author and do not necessarily represent those of RNIB. RNIB Registered Charity Number: 226227 Website: http://www.rnib.org.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: javascript and servlets.
A better approach would be to name all the fields file instead of fileX and then us the getParameterValues to get the enumeration of values taken from the fields named file very simple and elegant not for (int loop just a plain old while (enum.hasMoreElements()){ enum.nextElement().} if your javascrip relies on the field names, you can use the fields ID instead, because field ID isn't passed as parameter name [EMAIL PROTECTED] escribi: I have a form with multiple input name=file0 elements. The names are generated and range file0..n I'm trying (and failing) to retrieve the value of the input fields. String f =; f = request.getParameter(file0); works fine; The remainder appear inaccessible. In the docs ...webapps/tomcat-docs/servletapi/index.html I'm warned: You should only use this method when you are sure the parameter has only one value. If the parameter might have more than one value, use getParameterValues(java.lang.String). However, since each entry within the form has a variant name value, what parameter should I pass to the getParameterValues method to retrieve the multiple values? tc 5.0.27 in use. Regards DaveP. snip here * -- John Villar Gerente de Proyectos Computadores Flor Hard Soft 2058 C.A. www.florhard.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: javascript and servlets.
If your fields are all file uploads, then you probably can't get them through the regular HttpServletRequest.getParameter(). I'm curious though, what do you get from the first element (file0). Is it the file contents? What you need to do is submit the form as multipart form, and process posted boundaries. This article has everything that you'll need: http://www.javaworld.com/javaworld/jw-06-2001/jw-0622-filters-p4.html Don't forget to modify your form like this: form method=post action=/repository/getit name=form enctype=multipart/form-data On Fri, 3 Sep 2004 12:21:52 +0100 , [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: -Original Message- From: Ralph Einfeldt form method=get ... /form the query string can be found in the access log. (This might be turned of) How do I enable it please? From your last post with the source I think that each input tag has it's own form so only one field is submitted. I noted that the jscript adds extra input elements within the form, hence there are many, each with a differing name attribute. All within the same form. regards DaveP -- DISCLAIMER: NOTICE: The information contained in this email and any attachments is confidential and may be privileged. If you are not the intended recipient you should not use, disclose, distribute or copy any of the content of it or of any attachment; you are requested to notify the sender immediately of your receipt of the email and then to delete it and any attachments from your system. RNIB endeavours to ensure that emails and any attachments generated by its staff are free from viruses or other contaminants. However, it cannot accept any responsibility for any such which are transmitted. We therefore recommend you scan all attachments. Please note that the statements and views expressed in this email and any attachments are those of the author and do not necessarily represent those of RNIB. RNIB Registered Charity Number: 226227 Website: http://www.rnib.org.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: javascript and servlets.
i've just realised that you want to use input type=FILE. so you have to post FORM ACTION=... ENCTYPE=multipart/form-data METHOD=POST form -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Envoy : vendredi 3 septembre 2004 15:15 : [EMAIL PROTECTED] Objet : RE: javascript and servlets. -Original Message- From: Ralph Einfeldt If you have file0 through filen this should work: request.getParameter(file0); .. request.getParameter(filen); if file1 through filen are null against your expectations, I would say something is wrong on the client side. And so it was Ralph. No idea what, but I'm now iterating through the attribute values happily... except, Theinput type=file id=file0 name=file0 I enter a full path, e.g. c:\dir\dir\file.ext and the retrieved value is file.ext. I'm still missing a bit, but so far so good! Tks for the tips. regards DaveP -- DISCLAIMER: NOTICE: The information contained in this email and any attachments is confidential and may be privileged. If you are not the intended recipient you should not use, disclose, distribute or copy any of the content of it or of any attachment; you are requested to notify the sender immediately of your receipt of the email and then to delete it and any attachments from your system. RNIB endeavours to ensure that emails and any attachments generated by its staff are free from viruses or other contaminants. However, it cannot accept any responsibility for any such which are transmitted. We therefore recommend you scan all attachments. Please note that the statements and views expressed in this email and any attachments are those of the author and do not necessarily represent those of RNIB. RNIB Registered Charity Number: 226227 Website: http://www.rnib.org.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: javascript and servlets.
-Original Message- From: Marot Laurent i've just realised that you want to use input type=FILE. so you have to post FORM ACTION=... ENCTYPE=multipart/form-data METHOD=POST form That I didn't know. Thanks Laurent. Mike/John, I am now getting them via the request.getparameter() call, Just that I had a problem on the client end. f = request.getParameter(file0); while (f != null){ out.println(pfile : + f ); out.println(/p); // fn[numFiles]=f; numFiles++; f = request.getParameter(file+Integer.toString(numFiles)); System.err.println(Seeking + file+Integer.toString(numFiles)); } Is working well.. except for the path being curtailed, just returning the filename+ext. regards DaveP ** snip here ** -- DISCLAIMER: NOTICE: The information contained in this email and any attachments is confidential and may be privileged. If you are not the intended recipient you should not use, disclose, distribute or copy any of the content of it or of any attachment; you are requested to notify the sender immediately of your receipt of the email and then to delete it and any attachments from your system. RNIB endeavours to ensure that emails and any attachments generated by its staff are free from viruses or other contaminants. However, it cannot accept any responsibility for any such which are transmitted. We therefore recommend you scan all attachments. Please note that the statements and views expressed in this email and any attachments are those of the author and do not necessarily represent those of RNIB. RNIB Registered Charity Number: 226227 Website: http://www.rnib.org.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]