URL Connection Problem

Hi all,

I want to send applet parameters to web server using URL.And got many links explaining that.

I tried with following code.But gives IOException and as newbie I am confused how to run this so I can send data to web server.

try{

URLurl;

URLConnectionurlConn;

DataOutputStreamdos;

DataInputStreamdis;

url =new URL("http://webserver.our-intranet.com/cgi-bin/AddToDoItem");

urlConn = url.openConnection();

urlConn.setDoInput(true);

urlConn.setDoOutput(true);

urlConn.setUseCaches(false);

urlConn.setRequestProperty ("Content-Type","application/x-www-form-urlencoded");

dos =new DataOutputStream (urlConn.getOutputStream());

// String message = "NEW_ITEM=" + URLEncoder.encode(addTextField.getText());

String message ="NEW_ITEM=" + URLEncoder.encode("Hello");

dos.writeBytes(message);

dos.flush();

dos.close();

// the server responds by saying

// "SUCCESS" or "FAILURE"

dis =new DataInputStream(urlConn.getInputStream());

String s = dis.readLine();

dis.close();

if (s.equals("SUCCESS")){

// jTextField1.add

// addTextField.setText("");

System.out.println("Done");

}else{

System.out.println("Not Done");

}

}// end of "try"

catch (MalformedURLException mue){

System.out.println("mue error");

}

catch (IOException ioe){

System.out.println("IO Exception");

}

Plz help!!

Regards,

Palak

[2611 byte] By [palak_shaha] at [2007-11-26 13:50:50]
# 1
You need to print out the IOException text first, and post it here, but don't you need to set the request type to POST or PUT?
ejpa at 2007-7-8 1:27:48 > top of Java-index,Core,Core APIs...
# 2

Thanks ejp,

But I am not getting.how should I proceed to put information on url to send that to web browser.

Uptil I understood need to make url connection using URL and URLConnection objects.and confused ahead.If I want to pass simple "hello" to web server.

Or should Iuse Java script as I am passing values filled by user to web server to implement that.

But m obscure...

Regards,

Palak Shah

palak_shaha at 2007-7-8 1:27:48 > top of Java-index,Core,Core APIs...