I want to upload .csv file To servlet and parse it, but dont know how to open uploaded file [closed]

StackOverflow https://stackoverflow.com/questions/662642

  •  20-08-2019
  •  | 
  •  

Question

I have a form that allows user to select a .csv file and post it to a servlet. However I am having dificullty getting a handle on the file from the Java Servet on the server any ideas?

No correct solution

OTHER TIPS

I recommend using Apache Commons FileUpload

A mistake I make myself and see other people make often is in HTML rather than you serverside. Make sure you have enctype="multipart/form-data" in your form tag.

If that's ok see this:

http://coldjava.hypermart.net/servlets/upload.htm

Try OpenCSV for reading and parsing CSV files. I just tried it. It is very easy and quick. It is also with commercial-friendly license. So you can use it your production code as well.

Check out this link http://opencsv.sourceforge.net/

you can not open the file you upload.you need to use inputstream to parser the file.and

“Make sure you have enctype="multipart/form-data" in your form tag”

In java programming,any upload file just can use io to parser that.When you use servlet to parser the file,use request.getInputStream.

To Upload your csv file into the any one of the database then you have to save your file in a folder first by browse and selecting the file.then afterwords you have to read all the columns in the csv file using FileInputStream class ...

By using this code in your program FileInputStream fis=new FileInputStream(pathheader); FileOutputStream fos=new FileOutputStream(filenamehdr);

for more check here..Upload CSV file using Servlets

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top