Refactored type checking in UploadServlet.