Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 94635 invoked from network); 20 Dec 2006 04:52:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Dec 2006 04:52:16 -0000 Received: (qmail 30877 invoked by uid 500); 20 Dec 2006 04:52:10 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 30853 invoked by uid 500); 20 Dec 2006 04:52:10 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 30842 invoked by uid 99); 20 Dec 2006 04:52:10 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Dec 2006 20:52:10 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of andre.prasetya@gmail.com designates 66.249.82.236 as permitted sender) Received: from [66.249.82.236] (HELO wx-out-0506.google.com) (66.249.82.236) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Dec 2006 20:52:00 -0800 Received: by wx-out-0506.google.com with SMTP id i26so1909925wxd for ; Tue, 19 Dec 2006 20:51:39 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=evN8R9Th3UNiFO+ruj3gEN+i2UHMLt1qv5pqW0/gt135SpKlXM4KUV5d62PDNCafTbpRdBWeWU/E2mp+qexp0lLaDtF/9bzHieWpfbfQLIbxnViLpbR/mse5dA5AuZMexorr6NGMtaUw444e5f7HMcNYbDqtiEMQxN0cJXvHKCk= Received: by 10.70.131.19 with SMTP id e19mr11262214wxd.1166590299728; Tue, 19 Dec 2006 20:51:39 -0800 (PST) Received: by 10.70.96.11 with HTTP; Tue, 19 Dec 2006 20:51:39 -0800 (PST) Message-ID: <95bb02000612192051n22207fe6x9b8a3b291bc69626@mail.gmail.com> Date: Wed, 20 Dec 2006 11:51:39 +0700 From: "Andre Prasetya" To: "Tomcat Users List" Subject: Re: Servlet with POST Request In-Reply-To: <4588B1ED.5050103@progbits.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_15549_29925609.1166590299658" References: <45833AB7.6000907@progbits.com> <4eedb92a0612151851g194ca281p96fc2ec27ba581e5@mail.gmail.com> <45836F4A.4040204@progbits.com> <95bb02000612191856x1098d379se4439947c0e546f@mail.gmail.com> <4588B1ED.5050103@progbits.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_15549_29925609.1166590299658 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Why dont you try using PUT instead of POST ? I think put is more suitable for this as you can stream anything to servlet. if you insist on using post, i recommend getting the parameter and replace the newline with some chars like ':' this is an example on streaming an object using put HttpClient client = HTTP_CLIENT; PutMethod method = new PutMethod(getUrl().toString()); ByteArrayOutputStream byter = new ByteArrayOutputStream(); ObjectOutputStream out = null; byte[] response = null; try { out = new ObjectOutputStream(byter); out.writeObject(o); RequestEntity entity = new ByteArrayRequestEntity( byter.toByteArray()); method.setRequestEntity(entity); client.executeMethod(method); response = method.getResponseBody(); } finally { if (out != null) { out.close(); } method.releaseConnection(); } On 12/20/06, Scott Carr wrote: > > I am creating a client - server application that will process lines like: > > startjob > adduser > adduser > adduser > adduser > endjob > > adduser can be an unlimited amount of times. I want to process the > lines as they come into the Servlet, that way a seperate process could > be doing something to complete each of the tasks, while I am in the > process of working on reading the lines. > > I have written a Socket server of my own to do this before, I am now > trying to use Tomcat Servlet to do the same thing, because Tomcat > already some behind the scenes stuff already setup. > > Does this make sense? Am I totally off my rocker? (My wife would > definately agree with that last bit.) > > Andre Prasetya wrote: > > Why do you want to read POST by using reader ? I only use the stream > from > > request on a PUT request. > > > > > > On 12/16/06, Scott Carr wrote: > >> > >> Hassan Schroeder wrote: > >> > On 12/15/06, Scott Carr wrote: > >> >> Does a servlet require the use of a Content-Length for the Reader > >> to be > >> >> populated? > >> > > >> > A pretty cursory test seems to indicate not, but I could just be > lucky > >> > :-) > >> > > >> >> ...and I want to read each line as they come in, and handle the > >> >> request on > >> >> a line by line basis. > >> > > >> > Have you tried this yet? request.getReader() would seem to cover > >> > your situation, assuming this isn't binary data. > >> > > >> Hm, the reason I asked, is because of a test I ran. strLine is always > >> null. > >> > >> Using the following code for processRequest: > >> > >> response.setContentType("text/plain"); > >> > >> m_out = response.getWriter(); > >> m_bufRead = request.getReader(); > >> > >> while (true) { > >> strLine = m_bufRead.readLine(); > >> > >> if (strLine != null) { > >> if (strLine.startsWith("login")) { > >> ProcessLogin(); > >> } else if (strLine.startsWith("exit")) { > >> break; > >> } > >> } else { > >> try { > >> Thread.sleep(1000); > >> } catch (InterruptedException ex) { > >> ex.printStackTrace(); > >> } > >> } > >> } > >> > >> m_bufRead = null; > >> m_out.close(); > >> > >> --------------------------------------------------------------------- > >> To start a new topic, e-mail: users@tomcat.apache.org > >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > >> For additional commands, e-mail: users-help@tomcat.apache.org > >> > >> > > > > > > -- > Scott Carr > OpenOffice.org > Documentation Co-Lead > http://documentation.openoffice.org > > > --------------------------------------------------------------------- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > For additional commands, e-mail: users-help@tomcat.apache.org > > -- -Andre- PCs are like air conditioner, if you open Windows, they don't work ------=_Part_15549_29925609.1166590299658--