Think about it, it can't work in real world situations. You're handling requests from all over the world, hundreds of them at the time. Do you really want your servlet to wait for an ACK to see that the request has been delivered? No! You want to process it as fast as possbile and move on to the next one.
Yes, the servlet knows about it, after all it's writing to a socket and when the writing fails it knows so. But by then the request has been commited, and you're probably in the internal/caching part of the servlet. Also, there are several other issues. What if the user clicked on a button to go back, or typed a new URL? Do you know that the browser will really stop accepting the data, and you'll know that the user did that? We just have to write code delivering pages, but not assuming that the user received them. The only way to know for sure that a user has done and an action is by accepting the input from an action. On Tue, Oct 08, 2002 at 07:46:21AM -0400, Galbreath, Mark wrote: > Interesting test...Milt, what's your opinion on this. Good effort, in any > event! > > Mark > > -----Original Message----- > From: Michael Peceny [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, October 08, 2002 7:31 AM > > Not quite -- the client and the server are playing a "request-response > game", and when one of the two suddenly quits in the middle of the game, the > other should realize this... > > I could imagine that once the client stops waiting for the response (i.e., > the user hits the cancel button), there is an error on the server when it > attempts to send response data to the client (or is this indistinguishable > from the response data being lost/bogged down somewhere on the net? what > does the client do when the server attempts to send it some response data it > has stopped waiting for? does it send a "don't want your (from my point of > view unrequested) data" back the server?) ... and on to an answer (derived > from a simple test, so it's not necessarily comprehensive or true without > exception): > > ok, tested it, and actually there is an exception thrown when the client has > stopped listening. BUT... that exception isn't thrown within the servlet's > doGet() / doPost (), but rather by the servlet engine afterwards. > > Example: > > public void doPost( HttpServletRequest request, HttpServletResponse response > ) > throws ServletException, IOException > { > response.setContentType( "text/plain" ); > PrintWriter out = response.getWriter(); > > try { > out.write( "Line 1\n\r" ); > > // set a breakpoint here and, while the debugger is halted, click on > the > // browser's STOP/CANCEL button > > out.write( "Line 2" ); > out.flush(); > response.flushBuffer(); > // hmm... apparently, the servlet doesn't get told whether the data that is > flushed > // is accepted by the client or not > } catch ( Exception e ) { > System.err.println( "Exception: " + e.toString() ); > } > > return; > } > > The catch block doesn't get an exception. But after doPost() is left, the > servlet engine (New Atlanta ServletExec Debugger) reports the following: > > Responder.run() caught an IOException 1:Connection reset by peer: socket > write error Most likely the user broke the connection by stopping the > browser. > > So, an exception is actually thrown, the server does realize that the client > isn't listening any more (it doesn't tell the servlet, though). But > unfortunately we cannot handle it inside the doPost() method. > > ___________________________________________________________________________ > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body > of the message "signoff SERVLET-INTEREST". > > Archives: http://archives.java.sun.com/archives/servlet-interest.html > Resources: http://java.sun.com/products/servlet/external-resources.html > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html > -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html