The small program is driving me crazy!!!

My purpose is to let applet communicate with servlet using HTTP.
The servlet can respond to the POST from HTML form, so it ought
to be alright. The following is the applet code used to contact
the servlet, compiled OK and no exception thrown in running, but
there is no response from the servlet.

No problem with servlet's directory.
I'm using JSDK2.1, could it be the problem of JSDK?
Anyone has the same experience? Thanks!


  try
    {
      URL url = new URL(getCodeBase(), "/servlet/TestServlet");

      URLConnection con = url.openConnection();

      con.setDoOutput(true);

      // Turn off caching
      con.setUseCaches(false);
      con.setDefaultUseCaches(false);
      con.setRequestProperty("Content-Type","application/x-www-form-urlencoded");

      // Write the arguments as post data
      DataOutputStream out = new DataOutputStream(con.getOutputStream());
      out.writeBytes("message=hello");
      out.flush();
      out.close();

    }
    catch (SocketException e)
   {
    ...
   }

___________________________________________________________________________
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