Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 51281 invoked from network); 3 Apr 2005 01:06:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 3 Apr 2005 01:06:38 -0000 Received: (qmail 17002 invoked by uid 500); 3 Apr 2005 01:06:37 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 16060 invoked by uid 500); 3 Apr 2005 01:06:34 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 16046 invoked by uid 99); 3 Apr 2005 01:06:34 -0000 X-ASF-Spam-Status: No, hits=0.6 required=10.0 tests=URIBL_SBL X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from chiron.lunarpages.com (HELO chiron.lunarpages.com) (64.235.234.14) by apache.org (qpsmtpd/0.28) with ESMTP; Sat, 02 Apr 2005 17:06:34 -0800 Received: from pcp05109618pcs.potshe01.pa.comcast.net ([69.139.22.34] helo=[127.0.0.1]) by chiron.lunarpages.com with esmtpa (Exim 4.44) id 1DHtZP-0005a5-I2 for commons-user@jakarta.apache.org; Sat, 02 Apr 2005 17:06:31 -0800 Message-ID: <424F411C.1070002@omnytex.com> Date: Sat, 02 Apr 2005 20:04:28 -0500 From: "Frank W. Zammetti" Reply-To: fzlists@omnytex.com Organization: Omnytex Technologies User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jakarta Commons Users List Subject: Re: [fileupload] Re: Using parseRequest(request) more than once References: <20050403001758.51157.qmail@web88011.mail.re2.yahoo.com> <16d6c6200504021624299a71c4@mail.gmail.com> In-Reply-To: <16d6c6200504021624299a71c4@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - chiron.lunarpages.com X-AntiAbuse: Original Domain - jakarta.apache.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - omnytex.com X-Source: X-Source-Args: X-Source-Dir: X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N While I agree with Martin that it seems odd that you *have* to read from the stream twice, you know the requirements of your use case better than we do certainly... so be it :) Here's a suggestion, and mind you this is after about 10 seconds of thought, it may be completely wacky... How about creating your own version of InputStream that accepts an InputStream in the constructor and copies the entire stream to a byte array? Then you just override the required methods so you can use that as you would a regular InputStream, but you would have the ability to read from it as many times as you want (maybe add a restart() method?). Then, just modify FileUpload to use that class instead of a regular InputStream. In fact, I *think* the only required change (Martin can check me on this) is in FileUploadBase.java, line 334 in the current source: InputStream input = req.getInputStream(); to: InputStream input = new MyInputStream(req.getInputStream()); Would that do the trick for you? Am I missing something incredibly obviously stupid with the idea? Frank Martin Cooper wrote: > On Apr 2, 2005 4:17 PM, Navid Mehregani wrote: > >>It's not as easy as that. I'm modifying an existing >>code and your suggestion wouldn't be feasible in my >>case. > > > Well it's not possible to read the servlet input stream more than > once, because after it's been read, it's gone. So there's no viable > alternative, I'm afraid. > > -- > Martin Cooper > > > >>Navid >> >> >>--- Martin Cooper wrote: >> >>>First of all, please follow the conventions of the >>>mailing list and >>>prepend the name of the relevant component to the >>>subject line, in >>>square brackets. That way, people know at a glance >>>which component >>>your question is about. >>> >>>On Apr 2, 2005 12:00 PM, Navid Mehregani >>> wrote: >>> >>>>I have a HttpServletRequest object that's >>> >>>multipart >>> >>>>content (i.e >>> >>>FileUpload.isMultipartContent(request) == >>> >>>>true). >>>> >>>>I have to read the parameters of this request >>> >>>object >>> >>>>in several different functions. >>> >>>Why? I mean, why do you need to *read* them in >>>several different >>>functions? Why can't you read them once and then >>>pass them around? >>> >>>That's actually what you're going to have to do. >>>Once you've called >>>parseRequest(), the request input stream has been >>>consumed, and cannot >>>be read again. This is not something that FileUpload >>>can do anything >>>about - it's just how streams work. >>> >>>-- >>>Martin Cooper >>> >>> >>>>When I do the following in the first function: >>>>DiskFileUpload upload = new DiskFileUpload(); >>>>List items = upload.parseRequest(request); >>>> >>>>it works fine, but in subsequent functions, the >>>>parameters from the request object are missing. >>> >>>The >>> >>>>following returns zero: >>>>DiskFileUpload upload = new DiskFileUpload(); >>>>List items = upload.parseRequest(request); >>>>items.size() <-- This is zero. >>>> >>>>It seems as if the upload.parseRequest(request) >>>>changes the request object. What is the general >>>>work-around if someone wants to read the parameter >>> >>>of >>> >>>>a multipart request object more than once? >>>> >>>>Any help would be greatly appreciated. >>>> >>>>Thanks, >>>> Navid Mehregani >>>> >>>> >>> >>______________________________________________________________________ >> >>>>Post your free ad now! http://personals.yahoo.ca >>>> >>>> >>> >>--------------------------------------------------------------------- >> >>>>To unsubscribe, e-mail: >>> >>>commons-user-unsubscribe@jakarta.apache.org >>> >>>>For additional commands, e-mail: >>> >>>commons-user-help@jakarta.apache.org >>> >>>> >>> >>--------------------------------------------------------------------- >> >>>To unsubscribe, e-mail: >>>commons-user-unsubscribe@jakarta.apache.org >>>For additional commands, e-mail: >>>commons-user-help@jakarta.apache.org >>> >>> >> >>______________________________________________________________________ >>Post your free ad now! http://personals.yahoo.ca >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: commons-user-help@jakarta.apache.org > > > > > -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org