if the user tries to upload the file of other mime-type (content-type), this api throws the exception and your servlet / jsp has a chance to catch the exception.
This Java API can check if the binary contents of the uploaded file are really the PNG, JPEG, GIF or PDF.