Servletでmultipart/form-dataを受け取るにはJakarta Commons FileUpload
を利用するのが簡単です。
サンプル
ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory()); List items; try { items = upload.parseRequest(servletRequest); } catch (FileUploadException e) { throw new ServletException(e); } for (Object val : items) { FileItem item = (FileItem) val; if (item.isFormField()) { System.out.println("form data (" + item.getFieldName() + ": " + new String(item.get()) + ")"); } else { System.out.println("file found!"); } }