I am recording a video by camera of cell and convert in bytes, later sending to the servlet, with the method POST:
How receive this bytes in a servlet?Code:class UploadToServer extends Thread { public void run() { Upload(); } public void Upload () { HttpConnection http = null; OutputStream oStrm = null; InputStream iStrm = null; boolean ret = false; String url = "127.0.0.1/ServerVideo"; try { http = (HttpConnection) Connector.open(url); oStrm = http.openOutputStream(); http.setRequestMethod(HttpConnection.POST); http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); byte data [] = output.toByteArray(); oStrm.write(data,0,data.length); iStrm = http.openInputStream(); //ret = processServerResponse(http, iStrm); if (iStrm != null) iStrm.close(); if (oStrm != null) oStrm.close(); iStrm = http.openInputStream(); //ret = processServerResponse(http, iStrm); if (iStrm != null) iStrm.close(); if (oStrm != null) oStrm.close(); if (http != null) http.close(); } catch (IOException e) { e.printStackTrace(); } } }
Thanks for helping and sorry my english

Reply With Quote


