Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 18909 invoked from network); 2 Apr 2004 22:20:22 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 2 Apr 2004 22:20:22 -0000 Received: (qmail 98066 invoked by uid 500); 2 Apr 2004 22:19:38 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 97991 invoked by uid 500); 2 Apr 2004 22:19:37 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 97928 invoked from network); 2 Apr 2004 22:19:37 -0000 Received: from unknown (HELO smtp2.synygy.com) (207.106.136.38) by daedalus.apache.org with SMTP; 2 Apr 2004 22:19:37 -0000 Received: from localhost (unknown [127.0.0.1]) by smtp2.synygy.com (Postfix) with ESMTP id 8A557194084 for ; Fri, 2 Apr 2004 16:39:20 -0500 (EST) Received: from smtp2.synygy.com ([127.0.0.1]) by localhost (smtp2.synygy.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 03410-05 for ; Fri, 2 Apr 2004 16:39:20 -0500 (EST) Received: from wine.synygy.net (wine.synygy.net [10.12.0.218]) by smtp2.synygy.com (Postfix) with ESMTP id F31BC194010 for ; Fri, 2 Apr 2004 16:39:19 -0500 (EST) Received: by wine.synygy.net with Internet Mail Service (5.5.2657.72) id ; Fri, 2 Apr 2004 17:18:50 -0500 Message-ID: From: "Inger, Matthew" To: 'Jakarta Commons Developers List' Subject: RE: COMMONS UPLOAD QUESTION "request.getParameter()" Date: Fri, 2 Apr 2004 17:18:49 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2657.72) Content-Type: text/plain; charset="iso-8859-1" X-Virus-Scanned: by amavisd-new at synygy.com X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Try using the parse(HttpServletRequest req) method. The returned FileItem objects have a method "isFormField()" with returns true if the particular FileItem represents a field in a form which is not a file (seems kind of silly, since it's a "FileItem" class, yet it's representing something that's not a file). List l = fileUploadInstance.parse(req); Iterator it = l.iterator(); FileItem item = null; while (it.hasNext()) { item = (FileItem)it.next(); if (item.isFormField()) { // do processing for your fields } else { // do processing for your file } } I would personally like to see an HttpServletRequest implementation provided which would take the original request, pass it to a FileUpload instance for parsing, and process the returned FileItem instances so that things like "getParameter()" and so forth would work properly. (hmm.... maybe i should just write that class). -----Original Message----- From: Artstar910@aol.com [mailto:Artstar910@aol.com] Sent: Friday, April 02, 2004 4:20 PM To: commons-dev@jakarta.apache.org Subject: COMMONS UPLOAD QUESTION "request.getParameter()" I have been searching the Internet for a practical Java-based uploading solution that is standardized. I have found that there are many Java apps and tools that people have built for this purpose but I find that each have their short falls and must be customized to perform my tasks. My tasks are not complicated at all, but apparently there is no information on how to perform these task in the JavaDocs or even newsgroups. Here is what I am looking to do: I need to input the fields from this for into my database which is perfectly normalized. -------------------------------------------------------------------------- upload.jsp --------------------------------------------------------------------------
AUTHOR
ARTICLE SHORT DESCRIPTION
ARTICLE LONG DESCRIPTION *MAY BE NULL
ARTICLE CONTENT
-------------------------------------------------------------------------- Here is the catch. I want to input the text fields directly in to their appropriate fields in the database but I want the file field to grab the file name and input that in the newly inputted row. I also need the file to uploaded to a file folder on my server. I know to pull the file name to input it in the database I need to use the getName() method. My problem is in the fact that I do not know which method I need to use to parse the other fields in my form. On my other forms for inputting info into my database I use JSP and I use the request.getParameter. As you know this does not work with the multipart encryption. In the JavaDocs it does not directly say which method should be called to parse this information. I chose commons specifically because it had a multipart parser in it. I also like the fact that it is somewhat standardized. I need to make sure that I do this right because I find that some many people on the Internet write bad code and I would perfer not to fall into that. I like to build most of my stuff in JSP and it is easy to change into servlets if I need to. I have tried a few other methods but I find them very sloppy. I tried the 3-Step approach. Where you have a data input JSP which then goes to another JSP which parses the form and inputs the data into the database then calls the row that the data is in and places that info into a hidden field. Then that page displays the file input box for the user to select the file. Then once that form is submitted to the next JSP document it, in theory, is supposed to find the field in the database to insert the file name in the appropriate field and upload the document to a file on the server. I would appreciate it if you can steer me in the right direction or send me a snippet, or link to somewhere that documents this. Thank you very much, Matt Newman Student @ LACC artstar910@aol.com --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org