title: excel file upload using jsp and servlets
body: <p>Hi i have a code for reading the excel file data but in my code i have hard coded the file but i need to get the file using jsp enctype="multipart/form-data" can anyone help me to overcome this problem</p>
  
  <p>and my servlet code is </p>
  
  <p>public class TcExcelUpload extends HttpServlet {
      private static final long serialVersionUID = 1L;</p>
  
  <pre><code>/**
   * @see HttpServlet#HttpServlet()
   */
  public TcExcelUpload() {
      super();
      // TODO Auto-generated constructor stub
  }
  
  /**
   * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {           
              try {           
                   InputStream input = new BufferedInputStream(
                              new FileInputStream("SalesForce.xls"));
                  POIFSFileSystem fs = new POIFSFileSystem( input );
                  HSSFWorkbook wb = new HSSFWorkbook(fs);
                  HSSFSheet sheet = wb.getSheetAt(0);
  
  
                  Iterator rows = sheet.rowIterator();
                  while( rows.hasNext() ) {  
                      HSSFRow row = (HSSFRow) rows.next();
                      System.out.println("\n");
                      Iterator cells = row.cellIterator();
                      while( cells.hasNext() ) {
  
                          HSSFCell cell = (HSSFCell) cells.next();
                          if(HSSFCell.CELL_TYPE_NUMERIC==cell.getCellType())
                          System.out.print( cell.getNumericCellValue()+"     " );
                          else
                          if(HSSFCell.CELL_TYPE_STRING==cell.getCellType())
                              System.out.print( cell.getStringCellValue()+"     " );
                          else
                              if(HSSFCell.CELL_TYPE_BOOLEAN==cell.getCellType())
                              System.out.print( cell.getBooleanCellValue()+"     " );
                              else
                                  if(HSSFCell.CELL_TYPE_BLANK==cell.getCellType())
                                      System.out.print( "BLANK     " );
                                      else
                                  System.out.print("Unknown cell type");                         
                      }                        
                  }      
              } catch ( IOException ex ) {
                  ex.printStackTrace();
              }    
  }
  /**
   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  
  }
  </code></pre>
  
  <p>}
  In the above code i have hard coded my file name so can anyone help me how to get the file at runtime.</p>
  
  <p>Thanks in advance,</p>
  
  <p>Regards,
  Suganth A.</p>