Hi,
I am generating 5 requests per second on the tomcat server using the following program.
How will I know if the connection is refused by tomcat. If the server is overloaded
with requests it starts refusing them. I have to capture this using my program below.
can anybody please tell me how do I do it.
I am also not sure if the Threads that are refused connection are getting any response
back ..
Please help
Thanks,
Venkatesh.
public class TestTomcat extends Thread{
private static int request=0;
public void run() {
try{
String inputLine;
URL url = new URL("http://localhost:8080/examples/servlet/TestTomcat?request=" +
++request);
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
BufferedReader inp = new BufferedReader(
new InputStreamReader(
connection.getInputStream()));
while ((inputLine = inp.readLine()) != null)
System.out.println(inputLine);
inp.close();
}
catch(Exception e){}
}
public static void main(String[] args) {
int m=0;
try{
for (int p=0;p<100;p++){
for(m=0;m<5;m++){
TestTomcat rg= new TestTomcat();
rg.start();
}
Thread.sleep(1000);
}
}
catch(Exception e){}
}
}