I'm writing Java Web Application. I'm trying to to upload a file using multipart-config, but I get a NullPointerException when I call getPart() from request.
I'm using Tomcat 8 and Eclipse for JavaEE.
Here is part of servlet code:
...
@Override
protected void doPost(
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
Part filePart = request.getPart("json_file");
InputStream fileContent = filePart.getInputStream();
...
And here is form from JSP file:
...
<form action="${pageContext.request.contextPath}/processJson" method="POST" enctype="multipart/form-data">
<label for="json_file">Файл:</label>
<input type="file" name="json_file" id="json_file" accept=".json" />
<br /><br />
<div class="submit-container">
<input type="submit" name="ready" id="ready" value="Загрузить" />
</div>
</form>
...