views:

3160

answers:

2

Hi,

I have this code, can you help me to solve this problem?
I have written this code:

out = new DataOutputStream(urlConnection.getOutputStream());//exception occur

String content = (String) remoteUrlList.get(urlID + ".params");
content = (content == null ? "" : content + "&") + "content=" +   URLEncoder.encode(textArea.getText());
if (debug > 0) System.err.println("Capture: " + content);
out.writeBytes(content);
out.flush();
out.close();

// retrieve response from the remote host and display it.
if (debug > 0) System.err.println("Capture: reading response");
in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
String str;
while (null != ((str = in.readLine()))) {
  System.out.println("Capture: " + str);
}
in.close();

doneDialog.pack();
doneDialog.setVisible(true);

The error listing is:

   at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.Socket.connect(Socket.java:519)
        at java.net.Socket.connect(Socket.java:469)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
        at sun.net.www.http.HttpClient.(HttpClient.java:233)
        at sun.net.www.http.HttpClient.New(HttpClient.java:306)
        at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:795)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:743)
        at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:654)
        at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:832)
        at de.mud.jta.plugin.Capture.saveFile(Capture.java:339)
        at de.mud.jta.plugin.Capture.access$200(Capture.java:83)
        at de.mud.jta.plugin.Capture$4.actionPerformed(Capture.java:173)
        at de.mud.jta.plugin.Capture$10$1.actionPerformed(Capture.java:266)

I am trying this on my local network, so no issue of firewall..
Can anyone help?

krunal patel

A: 

The address that you are connecting should exist. e.g. if you are opening a connection to localhost on port 8080, then there should be a server listening on that port.

Rohit
A: 

maybe a firewall problem? check if you can reach the url through telnet by using: telnet url 80

Dominik Rockenschaub