I have been trying to send multipart/form-data to the server. I have found that the request never reaches the server. This is my client code, if I am missing something core in here.
public static void main(String args[]) { try { URL url = new URL(SERVERURL); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setDoInput(true); con.setDoOutput(true); con.setUseCaches(false); con.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + BOUNDARY); con.setRequestMethod("POST"); con.setRequestProperty("Connection", "Keep-Alive"); OutputStream out = con.getOutputStream(); DataOutputStream oos = new DataOutputStream(out); oos.writeBytes(TWOHYPHENS + BOUNDARY + LINEEND); oos.writeBytes("Content-Disposition: form-data; name=\"name\"" + LINEEND); oos.writeBytes(LINEEND); oos.write("HI".getBytes("UTF-8")); oos.writeBytes(LINEEND); oos.writeBytes(TWOHYPHENS + BOUNDARY + TWOHYPHENS + LINEEND); oos.flush(); con.connect(); oos.close(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } Thanks, Pankaj