Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 28644 invoked from network); 16 Apr 2008 16:26:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Apr 2008 16:26:36 -0000 Received: (qmail 67852 invoked by uid 500); 16 Apr 2008 16:26:12 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 67758 invoked by uid 500); 16 Apr 2008 16:26:12 -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 67712 invoked by uid 99); 16 Apr 2008 16:26:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Apr 2008 09:26:12 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [76.13.9.84] (HELO web65616.mail.ac4.yahoo.com) (76.13.9.84) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 16 Apr 2008 16:25:29 +0000 Received: (qmail 8415 invoked by uid 60001); 16 Apr 2008 16:25:41 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=FE8rTIvvUtywz1KWHMz/7SKTAyO+l3jISAy6xsrObHggRKbXHIuS5ZNShvFAw8nF9j1CxfH4uj/ldiJNe4NJuKZSx/XiiKiinHxIIDn/gDDIauwbS1dMvN16Ip9Uh1ZzsZ6/Z7Ih8msDCprOuBZfookLGdxlm5+R1ZaxxzA9Z/k=; X-YMail-OSG: hlan7tAVM1nULFVTTCbqkFRRRUwnttIWaRsfeJeL Received: from [201.25.255.117] by web65616.mail.ac4.yahoo.com via HTTP; Wed, 16 Apr 2008 09:25:41 PDT Date: Wed, 16 Apr 2008 09:25:41 -0700 (PDT) From: Danilo Luiz Rheinheimer Reply-To: danilo_lr@yahoo.com Subject: Re: Performace - long time to release connection To: Tomcat Users List In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <534843.6132.qm@web65616.mail.ac4.yahoo.com> X-Virus-Checked: Checked by ClamAV on apache.org Jim, Thanks for your help. I am not setting the content-length on my servlet code. But if I see the response headers (using firebug) I have this result : Content-Length: 4332 Content-Type: text/html But another tool I have show me the page size as 4276. If I print the size of my response with : s.getBytes().length (where s is my response, see code on previous message) I get the value 4276. So I think you can be right on the cause of the problem. But how is the right way of set the content lenght ? I try this : // other data headers response.setDateHeader ("Expires", 0); response.setContentType("text/html"); String s = ... // creates JSON String response.setContentLength(s.getBytes().length); PrintWriter w = response.getWriter(); w.write(s); response.setStatus(HttpServletResponse.SC_OK); The problem still happens. Then I try this : byte[] data = s.getBytes(); response.setContentLength(data.length); ServletOutputStream ouputStream = response.getOutputStream(); ouputStream.write(data, 0, data.length); ouputStream.flush(); ouputStream.close(); response.setStatus(HttpServletResponse.SC_OK); But still no solution. The response header keep showing Content-Length=4332. How I can set the Content-Length in a reliable way ? >From where this 4332 value comes from ? Danilo. --- Jim Cox wrote: > Does the client get a "Content-length" header, and > if so does the actual > length of the response body match? If not it has to > either timeout or wait > for the server to close the connection. > > On Wed, Apr 16, 2008 at 11:33 AM, Danilo Luiz > Rheinheimer < > danilo_lr@yahoo.com> wrote: > > > Hi, > > > > I have a Java application running on a Tomcat > server > > (last version of the 5.5 serie). Java version is > 6. > > I have a servlet inside this application who > returns > > json to the browser (if you do not know json it is > > just a text). > > This process it taking a very long time, > something > > like 10 seconds. > > I put some simple debug code inside my servlet to > > show how much time the servlet takes to process > it. > > The time is short like 0.5 seconds. > > Still to the browser it takes 10 seconds ! > > If I type the servlet url on the browser I can > see > > it returns the result fast (the json shows on the > > browser screen after 0.5 seconds). > > But it do not release the http connection to the > > server. It keeps the message 'receiving data from > ...' > > on the botton of the browser for almost 10 > seconds. > > There are not a big load on the server at the > moment > > of this tests. In fact it is only me. > > > > The resumed servlet code is something like this : > > > > > response.setHeader("Cache-Control","no-cache"); > > response.setHeader("Pragma","no-cache"); > > response.setDateHeader ("Expires", -1); > > > response.setHeader("Cache-Control","no-store"); > > response.setDateHeader ("Expires", 0); > > > > response.setContentType("text/html"); > > > > String s = ... // creates JSON String > > PrintWriter w = response.getWriter(); > > w.write(s); > > > > As you can see very standard I think. > > I have the no cache headers because the json is > > generated at every time and can not be cahed. > > > > Someone has any idea of what the problem is ? > > > > Danilo. > > > > > > > > > ____________________________________________________________________________________ > > Be a better friend, newshound, and > > know-it-all with Yahoo! Mobile. Try it now. > > > http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ > > > > > --------------------------------------------------------------------- > > 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 > > > > > ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ --------------------------------------------------------------------- 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