From users-return-181976-apmail-tomcat-users-archive=tomcat.apache.org@tomcat.apache.org Thu Jun 26 15:27:04 2008 Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 62274 invoked from network); 26 Jun 2008 15:27:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Jun 2008 15:27:04 -0000 Received: (qmail 65039 invoked by uid 500); 26 Jun 2008 15:26:55 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 64802 invoked by uid 500); 26 Jun 2008 15:26:54 -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 64790 invoked by uid 99); 26 Jun 2008 15:26:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jun 2008 08:26:54 -0700 X-ASF-Spam-Status: No, hits=-4.0 required=10.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [140.172.10.145] (HELO paris.boulder.noaa.gov) (140.172.10.145) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jun 2008 15:26:03 +0000 Received: from lynx.ngdc.noaa.gov (lynx.ngdc.noaa.gov [140.172.179.24]) by email.boulder.noaa.gov (iPlanet Messaging Server 5.2 HotFix 2.01 (built Aug 26 2004)) with ESMTPSA id <0K320013BTJYJE@email.boulder.noaa.gov> for users@tomcat.apache.org; Thu, 26 Jun 2008 15:26:22 +0000 (GMT) Date: Thu, 26 Jun 2008 09:26:22 -0600 From: John Cartwright Subject: reading POST body fails on 6.0.16, works on 6.0.14 To: Tomcat Users List Message-id: <4863B51E.6080400@noaa.gov> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7BIT User-Agent: Thunderbird 2.0.0.14 (X11/20080421) X-Virus-Checked: Checked by ClamAV on apache.org Hello All, I have a very simple doPost method that reads the body of a POST request. Seems to work fine on 6.0.14 but consistently fails to read the body correctly in 6.0.16. Can someone help me with what's wrong here? Thanks! -- john protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // read POST body StringBuffer sb = new StringBuffer(); try { BufferedReader reader = request.getReader(); String inputLine; while ((inputLine = reader.readLine()) != null) { sb.append(inputLine); } } catch (IOException e) { throw new IllegalStateException("Error reading request body"); } String content = sb.toString(); log.debug("read "+content.length()+" characters from POST body"); if (content.length() != request.getContentLength()) { log.warn("Expected content length of "+request.getContentLength()+" but only read "+content.length()+" characters"); } //write out read content to file PrintStream os = new PrintStream(new FileOutputStream("/tmp/post_body.txt")); os.println(content); os.close(); PrintWriter out = response.getWriter(); response.setContentType("text/plain"); out.println("Content Type: " + request.getContentType()); out.println("POST body contained " + request.getContentLength() + " characters"); out.println("read " + content.length() + " characters from POST body"); out.flush(); 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