I have a form:
<form action='?hasScenario=1' method='post' enctype='multipart/form-data'>
<input type='file' name='file'/>
<input type='submit' />
</form>
In tomcat 8.0 I want to do:
private void handleRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
Part filePart = request.getPart("file");
....
}
In documentation I see I should get null if user doesn't enter any value. I havn't (intentionally) configured anything special for multipart/file uploading in web.xml or server. But instead of null I get:
java.lang.IllegalStateException: Unable to process parts as no multi-part configuration has been provided
I would like to handle nicely cases, when some parameters are not provided, how to do that? Catching and doing nothing on IllegalStateException is not nice way for me - in case of no parameter I'd like to ask user for file instead of scaring him with 'error/warning' words.