Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > what is the relation between HTTPServletResponse setContentLength header and keep-alive

Reply
Thread Tools

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

 
 
Naresh Agarwal
Guest
Posts: n/a
 
      05-29-2004
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
 
Reply With Quote
 
 
 
 
ExGuardianReader
Guest
Posts: n/a
 
      05-29-2004
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Position of links in page header in relation with themes WT ASP .Net 1 11-04-2008 04:45 PM
What is the difference and relation between an interface and itsmethod? tenxian Java 4 04-27-2008 06:26 PM
Relation between Interface and Area for OSPF winds Cisco 1 02-10-2006 08:41 AM
relation between typeid and typeinfo class (related by friend ?) Ganesh C++ 3 05-10-2005 09:53 AM
HTTPServletResponse.setStatus and error page reformy@gmail.com Java 0 02-28-2005 11:49 AM



Advertisments