title: Getting null for the content type of png image
body: <p>I am getting <code>null</code> value when I am trying to get the content type of <code>png</code> image</p>
  
  <p>Below is how I am trying to get the content type in my <code>servlet</code>:</p>
  
  <pre><code>String contentType = getServletContext().getMimeType(image.getName());
  </code></pre>
  
  <p>I am getting <code>contentType = null</code> and <code>image.getName()</code> returns name of <code>png</code> image.</p>
  
  <p>I tried other way to get the content type of the same <code>png</code> image:</p>
  
  <pre><code>String contentType = new MimetypesFileTypeMap().getContentType("imageName.png");
  </code></pre>
  
  <p>Above code gives me <code>contentType = application/octet-stream</code>.</p>
  
  <p>My question is why I am getting different content type for the same image, and what should I do so that I will get the correct content which is <code>image/x-png</code> for <code>.png</code> type of images</p>