/** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub String appPath = request.getServletContext().getRealPath(""); String filePath = ""; for (Part part : request.getParts()) { String fileName = extractFileName(part); filePath = appPath + File.separator + fileName; part.write(filePath); System.out.println("Wrote file to " + appPath + File.separator + fileName); } CSVReader reader = new CSVReader(new FileReader(filePath)); String[] nextLine; ArrayList<DataBean> data = new ArrayList<DataBean>(); while ((nextLine = reader.readNext()) != null) { // nextLine[] is an array of values from the line System.out.println(nextLine[0] + nextLine[1]); DataBean bean = new DataBean(); bean.setUsername(nextLine[0]); bean.setPassword(nextLine[1]); data.add(bean); } // Remove Username,password header data.remove(0); request.setAttribute("data", data); request.getRequestDispatcher("output.jsp").forward(request, response); }