Now to deal with some data in CSV format, just want to upload the file to the server, then import MySQL, and then do the subsequent processing.
Jkd1.7,servlet 3.0 and Tomcat 7.0 are used. Since servlet 3.0 directly supports file uploads, it is good to call the method directly.
There is also an official tutorial.
Http://docs.oracle.com/javaee/7/tutorial/doc/servlets016.htm#BABDGFJJ.
This is the basic thing to do, but there are two points to note:
1 I use the IDE is eclipse,eclipse when running the use of a virtual directory, not the Web application is located in the directory, you need to modify the server settings.
Eclipse default is the first item, need to change to the second item, direct modification is not possible, because cannot select.
Modify the method to delete the original Tomcat server, create a new server, do not add any items, modify and then add the project.
2 to get the server path, you need to use Request.getservletcontext (). Getrealpath ("") to get the root directory.
3 examples of self-contained getname methods have some problems that need to be adjusted themselves.
Java File Upload Example