I want to call the doPost and doGet methods of a servlet from an applet
and pass some parameters with it.
I'm using a class to do the job.I call the sendMessage(Properties, int)
method of the class

public InputStream sendMessage(Properties args, int method) throws
IOException {

        if (method == GET) {

            URL url = new URL(servlet.toExternalForm() + "?" +
toEncodedString(args));

            return url.openStream();

        } else {

            URLConnection conn = servlet.openConnection();

         conn.setDoInput(true);
            conn.setDoOutput(true);
            conn.setUseCaches(false);

     // Work around a Netscape bug

conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");



            // POST the request data (html form encoded)

     DataOutputStream out = new
DataOutputStream(conn.getOutputStream());

     if (args != null && args.size() > 0) {

  out.writeBytes(toEncodedString(args));
      }
            out.flush();
            out.close();

         // Read the POST response data

            return conn.getInputStream();

        }
    }

However i don't seem to be able to invoke the doPost method. Can anyone
help me?

___________________________________________________________________________
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