I use this successfully to post from java applications.  If I remember  correctly, I 
got the connection settings from Bruce Eckel's Thinking In Java.

protected static BufferedReader connectToURL(String siteURL, String parm dayToCheck)
         throws MalformedURLException, IOException
   {
      URL url = new URL(siteURL);
      URLConnection urlc = url.openConnection();
      urlc.setDoOutput(true);
      urlc.setDoInput(true);
      urlc.setAllowUserInteraction(false);
      DataOutputStream site = new DataOutputStream(urlc.getOutputStream());
      site.writeBytes(getQuery(parm));
      site.close();
      return (new BufferedReader(new InputStreamReader(urlc.getInputStream())));
   }

On Fri, 28 May 1999 02:17:40 -0600, Fan Wu <[EMAIL PROTECTED]> wrote:

>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

___________________________________________________________________________
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