0

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>
...
Alex M
  • 19
  • 1
  • Provide the stack trace in your question. – user207421 Jun 16 '19 at 23:12
  • looks like there may be a problem with chrome (lol) https://stackoverflow.com/questions/46663063/inputs-accept-attribute-doesnt-recognise-application-json – juju Jun 17 '19 at 12:28

0 Answers0