i am new with servlet programming, i need to develop a .WAR
API using servlet which will upload only xlsx files to a specific path in server (this API will be using by WebFocus (a programming language for reporting))
the specific path will be in a hidden filed of html <form>
here is my HTML
<html>
<body>
<form action="UploadServlet" method="Post" enctype="multipart/form-data">
Select File:<input type="file" name="fname"/><br/>
<input type="hidden" name="path" value="G:/newFolder" />
<input type="submit" value="upload"/>
</form>
</body>
</html>
now what should write inside my UploadServlet.java
file in order to upload xlsx files into path defined in path hidden filed
currently in my UploadServlet.java i used MultipartRequest
and it uploads the file to destination correctly but i want the distenation to be the value of path hidden field of the <form>
import java.io.*;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import com.oreilly.servlet.MultipartRequest;
public class UploadServlet extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
MultipartRequest m=new MultipartRequest(request,"g:/newFolder");
out.print("successfully uploaded");
}
}
any help would be much appreciated.