This is actually close to being OT, but I think many are interested in how
to do this.

I'm trying to post to a JSP from a Java class.  I absolutely can't get the
thing to work.  The post is always completely empty.  Here is my code:

      URL url = new URL("http://www.blah.com/blah.jsp");
      URLConnection connection = url.openConnection();
      ((HttpURLConnection)connection).setRequestMethod("POST");
(yes, I know the setRequestMethod is probably unnecessary)
      connection.setDoInput (true);
      connection.setDoOutput(true);
      connection.setUseCaches(false);
      connection.setRequestProperty( "content-type",
"application/x-www-form-urlencoded" );
      PrintStream outStream = new
PrintStream( connection.getOutputStream() );
      String blah = "hey=there";
      outStream.println(blah);
      outStream.flush ();
      outStream.close();

I've hit JavaSoft message boards and tried everything that was posted...it
just doesn't work.

Please help if you have any solutions.

phil

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to