When submitted the Java servlet's doPost method will receive the request, extract the name of the file from the Http request header, read the file contents from the request and output the file to the local upload directory.
(bad code)
public class FileUploadServlet extends HttpServlet {
...