Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to explicitly terminate http connection from server with no response header

Tags:

java

servlets

I am developing a server simulator for one of my client application. I am using GlassFish server. I have to simulate a http connection terminate condition in my server application.

Is there a way by which I can explicitly terminate a connection from server side such that client does not receive any response header. Currently I have tried many options like closing the response outputStream. But in every case a http 200 OK message is delivered to the client application. I would like to consume the http-request and do not want to return anything to the client.

I am using a simple conrtroller servlet and had overridden doGet() and doPost() functions.

like image 864
Gagandip Avatar asked Jun 11 '10 19:06

Gagandip


1 Answers

You're going to have difficulty persuading an appserver to do this, they're designed to be robust.

I suggest taking a look at Jetty, which is an embeddable and highly configurable HTTP/servlet framework which you can use as alternative to the appserver's built-in support. There's a good chance you'll be able to configure it with a customized connection handler, and hopefully perform your specific connection terminations.

like image 154
skaffman Avatar answered Nov 14 '22 22:11

skaffman