Hai everyone,

I am trying to generate the POST action from my servlet, but I am getting an
Exception thrown. The code goes as follows:

import java.io.*;
import java.util.*;
import java.net.*;
public class FormTest


        public static void main(String args[]) {
                FormTest form = new FormTest();
                form.send();
        }

        public void send()

                try

                        URL url;
                        HttpURLConnection urlConn;
                        DataOutputStream printout;
                        DataInputStream input;
                        url = new URL ("http://testserver.com/test.asp");
                        urlConn = (HttpURLConnection) url.openConnection();
                        urlConn.setDoOutput(true);
                        urlConn.setUseCaches (false);
                        urlConn.setRequestMethod("POST");
                        urlConn.setRequestProperty ("Content-Type",
"application/x-www-form-urlencoded");
                        System.out.println("Response Code: " + 
urlConn.getResponseCode());
// "IOException :Operation timed out: no further information" is thrown here
                        System.out.println("Response Message: 
"+urlConn.getResponseMessage());
                        printout = new DataOutputStream (urlConn.getOutputStream());


                        String content = "username=Test&password=tango";
                        System.out.println("Posting : " + content ) ;
                        printout.writeBytes(content);
                        printout.flush ();
                        printout.close ();

                        input = new DataInputStream (urlConn.getInputStream ());
                        String str;
                        while (null != ((str = input.readLine())))

                                System.out.println (str);
                        }
                        input.close ();

                }catch(MalformedURLException me)

                        System.err.println("MalformedURLException: " + me);
                }catch (IOException ioe)

                        System.err.println("IOException: " + ioe.getMessage()); }
        }
}

"IOException :Operation timed out: no further information" this exception
has been thrown while trying to getResponseCode from HttpURLConnection.
Can someone tell me what could be the reason? Or Am I doing something wrong?

Thanks in advance for your help

- Tango

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to