I do this with just the following code:
URL url = new URL("http://www.blah.com/blah.jsp");
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
So maybe try to reverse the setDoOutput and setDoInput...?
Scott
> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Phil Swenson
> Sent: Thursday, May 25, 2000 9:11 PM
> To: [EMAIL PROTECTED]
> Subject: POSTing to a JSP from a Java class - Getting desperate!
>
>
> 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
>
===========================================================================
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