what is the relation between HTTPServletResponse setContentLength header and keep-alive

Discussion in 'Java' started by Naresh Agarwal, May 29, 2004.

  1. Hi

    Is there any relation between setConentLength header of
    HTTPServletResponse and whether the server will "keep-alive" the
    socket connection?

    I want HTTPServletResponse to *close* the socket after sending the
    response. For this I'm closing the OutputStream after writing the
    data. But still socket is not closed and client keeps on waiting to
    read from socket.

    Is there way I can enfore HTTPServletResponse to close the socket?

    thanks,
    Naresh
     
    Naresh Agarwal, May 29, 2004
    #1
    1. Advertising

  2. Re: what is the relation between HTTPServletResponse setContentLengthheader and keep-alive

    Naresh Agarwal wrote:

    > Hi
    >
    > Is there any relation between setConentLength header of
    > HTTPServletResponse and whether the server will "keep-alive" the
    > socket connection?
    >
    > I want HTTPServletResponse to *close* the socket after sending the
    > response. For this I'm closing the OutputStream after writing the
    > data. But still socket is not closed and client keeps on waiting to
    > read from socket.
    >
    > Is there way I can enfore HTTPServletResponse to close the socket?
    >
    > thanks,
    > Naresh


    It is the browser which opens the connection, and if it's using HTTP 1.1
    (most do noawadays though you can often disable it), and if it is either
    not going through a proxy, or the proxy server maintains the 1.1
    keepalive connection, then it will maintain the TCP/IP connection in
    order to make subsequent HTTP requests a bit faster.

    In 1.0 there was a keepalive header which could be specified by the
    browser in its request: http://www.io.com/~maus/HttpKeepAlive.html

    If you don't want this use

    response.setHeader("Connection", "close");

    in your servlet: http://www.jmarshall.com/easy/http/#http1.1s4

    Nige
     
    ExGuardianReader, May 29, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luiz Alberto Gibson da Costa

    web chat development, http header connection: keep-alive

    Luiz Alberto Gibson da Costa, Aug 6, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    616
    Luiz Alberto Gibson da Costa
    Aug 6, 2003
  2. Wilson Chew
    Replies:
    0
    Views:
    346
    Wilson Chew
    Jul 20, 2004
  3. David
    Replies:
    1
    Views:
    902
    Christos TZOTZIOY Georgiou
    Jul 28, 2004
  4. Replies:
    0
    Views:
    687
  5. hisan
    Replies:
    1
    Views:
    1,364
    Dan Stromberg
    Jun 25, 2012
Loading...

Share This Page