i have a (with Tomcat 4) small program used to call a servlet via the URLConnection class , sometime java.net.ConnectException occurs , sometime it runs correctly , please let me know how to fix this. Thanks a lot
Here is my code
................
try
{
URL url = new URL("http://localhost:8080/myapp/servlet/myservlet");
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
PrintWriter out = new PrintWriter(connection.getOutputStream());
out.println("request");
out.close();
//here Exception: java.lang.NullPointerException:
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
while(!this.m_isReply){
inputLine = in.readLine();
if(inputLine!=null){
System.out.println("Reply: "+inputLine);
}
}
}catch(ConnectException ex){
}catch(InterruptedIOException ex){
}catch(Exception ex){
}

