Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URLConnection writing problem

 
moneer mohammed
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
i am try to write some data to the servlet but no data going and when i put same address in browser it working but from my programme the servlet not receiving any request

import java.io.*;
import java.net.*;


public class test {
public static void main(String[] args) {

URL url;
try {
url = new URL("http://localhost:8080/xxxx/ReconciliationReport");

URLConnection connection = url.openConnection();
connection.setDoOutput(true);

connection.connect();





OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
writer.write("testToSend");
writer.flush();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
}
 
Imran Akbar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


does it throw any Exception? could you please elaborate?



 
moneer mohammed
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry i forgot to say i am not getting any exception
 
Imran Akbar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look on the below thread it has the solution for your question

http://www.coderanch.com/t/494979/sockets/java/Working-HttpsURLConnection
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic