Java File Upload Example

Source: Internet
Author: User
Tags tomcat server

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.