title: Servlet for file upload - contentType returning 'none' when file extension in CAPS - why?
body: <p>My Java Servlet processes a file sent through a form on my JSP page. I want to accept image files only. So first thing the servlet does is check to see if the content-type is that of an image.</p>
  
  <p>To check the content-type, I use :</p>
  
  <pre><code>File f = new File(fieldValue); // Create a FileItem object to access the file.
  
  // Get content type by filename.
   String contentType = getServletContext().getMimeType(f.getName());                               
  if(contentType == null) contentType = "none";
  
  if(contentType.startsWith("image")) {
     //call methods - resize photo
  }
  </code></pre>
  
  <p>The problem? It will accept an image file, so long as the extension (.jpg, .png, etc) is NOT capitalized. When the file extension is in CAPS (ex. myphoto.JPG) the call to <code>getServletContext().getMimeType(f.getName())</code> returns <code>null</code>.</p>
  
  <p>My servlet changes the entire file name to lowercase letters, but that still doesn't make a difference if the file is submitted with capital letters for its extension.</p>
  
  <p>What can I do to fix this issue? </p>