Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 99641 invoked by uid 500); 16 Aug 2001 19:32:38 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: tomcat-user@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 99617 invoked from network); 16 Aug 2001 19:32:38 -0000 Received: from rm-rstar.sfu.ca (root@142.58.120.21) by h31.sny.collab.net with SMTP; 16 Aug 2001 19:32:38 -0000 Received: from cultus.sfu.ca (cultus.sfu.ca [142.58.101.5]) by rm-rstar.sfu.ca (8.10.1/8.10.1/SFU-5.0H) with ESMTP id f7GJWde24888 for ; Thu, 16 Aug 2001 12:32:39 -0700 (PDT) Message-Id: <200108161932.f7GJWde24888@rm-rstar.sfu.ca> Content-Type: text/plain Content-Disposition: inline To: tomcat-user@jakarta.apache.org From: "Rob S." Organization: Student X-Sender: rslifka@popserver.sfu.ca Mime-Version: 1.0 Reply-To: "Rob S." Date: Thu, 16 Aug 2001 12:32:39 PDT X-Mailer: SFUwebmail 2.70 Subject: Re: Bug in ServletResponse.flushBuffer() in Tomcat 4.0b7? X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N While this may be a Tomcat problem, you should really look at your design. Why? Even if there is a problem and it's fixed, you'll still have your original problem if the network is slow. + You could use javascript to disable the button (or not allow submitting) after it's been clicked on once. I personally abhor JavaScript but it comes in handy sometimes. + Stick an token into your submit page and keep a copy of it in the session. When the page is submittted, remove the token from the session. Repeated clicks will have no token in the session, so subsequent requests will fail. + I'm sure there are more ways... - r On Thu, 16 Aug 2001 14:14:52 -0500 tomcat-user@jakarta.apache.org wrote: > I'm having problems using ServletResponse.flushBuffer() and Tomcat 4.0b7. > The following servlet demonstrates. > > What I want it to do is print out the title and the "Test 1" line. Then, > pause for 10 seconds and print out the "Test 2" line. It doesn't work the > first time through. However, if I then hit Refresh in my browser after > going through it once, you can see clearly that it prints out the first > line pauses and prints out the last line as I would expect it to. Is this a > bug? Can someone else reproduce this? > > The reason I want to get this to work is that I have a servlet where I have > a page with a Submit button on it, then on the next page, there is > sometimes a few second lag while performing an update on a > directory/database. I've had problems in the past where users click the > Submit multiple times because they think it's stuck. Actually, it's not, > it's just slow. So, what I want to do is print out at least the top part of > the page so that the Submit button/previous page is no longer available for > them to click on. If someone could fix this for the final version of Tomcat > 4, I would greatly appreciate it. Either that or, if anyone else knows of a > work around, that would be appreciated too. > > Thanks, Jon > > import java.io.*; > import javax.servlet.*; > import javax.servlet.http.*; > > public class SimpleServlet extends HttpServlet > { > public void doGet(HttpServletRequest req, HttpServletResponse resp) throws > IOException > { > try > { > resp.setContentType("text/html"); > > PrintWriter pw = resp.getWriter(); > > pw.println("SimpleServlet"); > > pw.println("

Test 1

"); > > pw.flush(); > > resp.flushBuffer(); > > Thread.sleep(10000); > > pw.println("

Test 2

"); > > pw.println(""); > > pw.close(); > } > catch(Exception e) > { > System.out.println(e); > } > } > }