title: Sending a image to servlet in java how to get the image in servlet
body: <p>I am sending a image from android phone to server which is a servlet I am using the HttpClient and HttpPost for this and ByteArrayBody for storing the image before sending.</p>
  
  <p>how do i extract the image from the post request in Servlet.</p>
  
  <p>Here is my code for sending the post request</p>
  
  <pre><code>String postURL = //server url;
  
  HttpClient httpClient = new DefaultHttpClient();
  HttpPost postRequest = new HttpPost(postURL);
  
  ByteArrayBody bab = new ByteArrayBody(imageBytes,"file_name_ignored");
  MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
  reqEntity.addPart("source", bab);
  postRequest.setEntity(reqEntity);
  
  HttpResponse response = httpClient.execute(postRequest);
  </code></pre>