This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes URLConnection writing problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "URLConnection writing problem" Watch "URLConnection writing problem" New topic
Author

URLConnection writing problem

moneer mohammed
Ranch Hand

Joined: Feb 18, 2005
Posts: 66
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();
}

}
}


java_just
Imran Akbar
Ranch Hand

Joined: May 06, 2010
Posts: 63


does it throw any Exception? could you please elaborate?



moneer mohammed
Ranch Hand

Joined: Feb 18, 2005
Posts: 66
sorry i forgot to say i am not getting any exception
Imran Akbar
Ranch Hand

Joined: May 06, 2010
Posts: 63
Look on the below thread it has the solution for your question

http://www.coderanch.com/t/494979/sockets/java/Working-HttpsURLConnection
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URLConnection writing problem
 
Similar Threads
httpclient athentification issue
Pass parameter from JApplet to php file using POST method
post html login
send data in java application through post method
Login to web server with HttpClient