Try these changes ......i made in ur code


>From: "Hindfelt, Mattias" <[EMAIL PROTECTED]>
>Reply-To: "A mailing list for discussion about Sun Microsystem's Java
>        Servlet API Technology." <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: UrlConnections problem.
>Date: Thu, 18 May 2000 11:15:56 +0200
>
>Hi,
>I have a problem with UrlConnections. I have to call a UrlConnections from
>a
>servlet and that has caused same wierd stuff. If I change them URL to for
>example yahoo.se then everything works (get method), but as soon as I use
>post method it doesn't work. (and yes the  parameters are right)
>Anyone got any idea? Due to the fact that the try{} doesn't giva any
>exception there's no printed error message..
>
>
>  greetings Matt
>
>    try{
>       URL url = new URL("http://adress/servlet/package.file");
>       HttpURLConnection urlConn = (HttpURLConnection)url.openConnection();
>       urlConn.connect();
>       urlConn.setDoOutput(true);
        urlConn.setDoInput(true);<---------------
>       urlConn.setRequestMethod("POST");
>       String postStr = URLEncoder.encode("para1")+"="
>+URLEncoder.encode(para1)+"&"+URLEncoder.encode("para2")+"="
>+URLEncoder.encode(para2)
>+"&"+URLEncoder.encode("para3")+"="+URLEncoder.encode(para3)
>;<----------------
>       DataOutputStream  urlOut = new
>DataOutputStream(urlConn.getOutputStream());<--------------
>       urlOut.writeBytes(postStr);<----------------
>       urlOut.close();
>       BufferedReader in = new BufferedReader(
>         new InputStreamReader(
>         urlConn.getInputStream()));
>       String inputLine;
>       while ((inputLine = in.readLine()) != null)
>         System.out.println(inputLine);
>       in.close();
>       >    }catch (Exception e) {
>       response.setContentType("text/html");
>       PrintWriter out = new PrintWriter (response.getOutputStream());
       //I am not sure but i guess u got to get the OutputStream ...before u
do anything else using the response....
>       e.printStackTrace(out);
>       out.close();
>    }
>
>___________________________________________________________________________
>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

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

___________________________________________________________________________
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