Receiving file from
jsp using action form
ImportExcelForm myForm = (ImportExcelForm)form;
FormFile myFile = myForm.getTheFile();
i am accepting an excel file, i need to read this excel and need to distribute the data into different database tables.
i am rewriting this excel file in to local disk(server) as POI api accepts only io file.
InputStream inpstr= myFile.getInputStream();
FileOutputStream fos=new FileOutputStream("./BO.xls",false);
BufferedInputStream reader=new BufferedInputStream(inpstr,4096);
BufferedOutputStream writer=new BufferedOutputStream(fos,4096);
byte[] buf=new byte[4096];
int byteRead;
while ((byteRead=reader.read(buf,0,4096))>=0) {
writer.write(buf,0,byteRead);
}
reader.close();
writer.flush();
writer.close();
inputStream = new FileInputStream(xlsPath);
fileSystem = new POIFSFileSystem(inputStream);
HSSFWorkbook workBook = new HSSFWorkbook(fileSystem);
HSSFSheet sheet = workBook.getSheetAt(0);
but i want to pass the file from the browser directly to POI api and user should be able to upload multiple files at a time