1

i am using NetBeans, and i am working on a jsp page that allows the upload of a zip file. The zip file contains 6 CSV files, that is to be written to the SQL database.

My question is, how do i go about allowing the user to upload the file, unzip it in the jsp page, and allow me to read the file? Thanks in advance!

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
Melvin
  • 13
  • 1
  • 3
  • 1
    Wow, you're the third user in two days who asks **exactly** the same. Homework? Classmates? Colleagues? See http://stackoverflow.com/questions/3771903/how-do-i-bootstrap-a-zip-file-to-jsbc-database-using-jsp-and-servlets and http://stackoverflow.com/questions/3768104/jsp-servlets-how-do-i-upload-a-zip-file-unzip-it-and-extract-the-csv-file – BalusC Sep 23 '10 at 11:49
  • @BalusC hahaha, nice observation :) – Bozho Sep 23 '10 at 11:56
  • hey thanks nice people of stackoverflow, i have found the answer. yes, it's a project, and fortunately the information i needed were hidden somewhere in the slides. some useful link http://www.javazoom.net/jzservlets/uploadbean/uploadbean.html, http://opencsv.sourceforge.net/ and http://commons.apache.org/fileupload/using.html – Melvin Sep 24 '10 at 00:53

1 Answers1

3
  1. Add an <input type="file"> and make your form have enctype="miltipart/form-data"
  2. Use commons-fileupload to obtain the byte[] of the file (in a servlet of yours)
  3. Use java.util.zip.* to extract the files. See here
  4. Either parse the CVS (here) or if your database has an utility to import CSV, pass the files using Runtime.exec(..)
Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
  • @Melvin - if an answer works for you, you can mark it as accepted (tick below the vote counter) – Bozho Sep 24 '10 at 03:28