You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Michael Yates <ya...@nortelnetworks.com> on 2003/04/15 04:14:48 UTC

Tomcat 4.1.24 Servlet connection:close

Hi all,

I am using Tomcat 4.1.24 on Solaris 8 with JDK 1.4.1_01
I was wondering whether anyone has had any success in forcing the socket to
close from a servlet by doing code like the following:

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
  // do normal servlet processing to get a result

  response.setHeader("Connection","close");            
  
  PrintWriter out = response.getWriter();
  out.print(result.getResultString());

  out.flush();
}

I don't want to force the connection closed on every request (only when
something goes wrong in my back end processing). However running netstat on
my Solaris box whilst making requests shows that the connection never
closes. It just keeps on getting reused regardless of whether I specify
Connection: close in the response header or not.

Any help appreciated.

Michael