On the jsp page, you must send the servlet an additional string value when you press the button (the button that loads the file).

"<input type=\"submit\" value=\"Upload File\"></input>" 

How to do it in the POST method?

 if(c.getDocument() == null) { out.println("Загрузка документа:<br><br>" + "Выбрать файл для загрузки: <br />" + "<form action=\"/upload\" method=\"post\"" + "enctype=\"multipart/form-data\">" + "<input type=\"file\" name=\"file\" size=\"50\"/>" + "<br />" + "<input type=\"submit\" value=\"Upload File\"></input>"+ "</form>"); } else { out.println(c.getDocument()); } 
  • I do not rummage in Java, but to transfer the value of a button to the server, it is necessary for it to define the name attribute with the value you need, that is, as for any other form element ... - Roman Grinyov
  • I tried - not that ... - Igor Gorbunov

0