title: How to get the data from Excel sheet into out jsp page?
body: <p>I tried to read an excel file and display it in a jsp page, i use this code below but it get an error message.</p>
  
  <p>Code:</p>
  
  <pre><code>&lt;%@page import="org.apache.poi.hssf.usermodel.HSSFSheet"%&gt;
  &lt;%@page import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%&gt;
  &lt;%@page import="org.apache.poi.hssf.usermodel.HSSFRow"%&gt;
  &lt;%@page import="org.apache.poi.hssf.usermodel.HSSFCell"%&gt;
  &lt;%@page import="java.io.*" %&gt;
  &lt;%@page import="java.util.*" %&gt;
  &lt;html&gt;
  &lt;table border="1"&gt;
  &lt;%
   short a=0;
    short b=1;
    short c=2;
    short d=3;
    int i=0;
     String   value1="", value2="",value3=" ", value4="";
      String filename ="a.xlsx"; 
      if (filename != null &amp;&amp; !filename.equals("")) {
      try{
      FileInputStream fs =new FileInputStream(filename);
      HSSFWorkbook wb = new HSSFWorkbook(fs);
      for (int k = 0; k &lt; wb.getNumberOfSheets(); k++){
      int j=i+1;
      HSSFSheet sheet = wb.getSheetAt(k);
      int rows  = sheet.getPhysicalNumberOfRows();
      for (int r = 0; r &lt; rows; r++){
      HSSFRow row   = sheet.getRow(r);
      int     cells = row.getPhysicalNumberOfCells(); 
      out.write("&lt;br&gt;");
      HSSFCell cell1  = row.getCell(a);
        value1 = cell1.getStringCellValue();
        HSSFCell cell2  = row.getCell(b);
          value2 = cell2.getStringCellValue();
           HSSFCell cell3  = row.getCell(c);
           value3 = cell3.getStringCellValue();
            HSSFCell cell4  = row.getCell(d);
            value4 = cell4.getStringCellValue();
      %&gt;
      &lt;tr&gt;&lt;td&gt;&lt;%=value1%&gt;&lt;/td&gt;&lt;td&gt;&lt;%=value2%&gt;&lt;/td&gt;&lt;td&gt;&lt;%=value3%&gt;&lt;/td&gt;&lt;td&gt;&lt;%=value4%&gt;&lt;/td&gt;&lt;/tr&gt;
      &lt;%
      }
          i++;
      }
      }
      catch(Exception e){
          System.out.println(e);
      }
      }
      %&gt;
      &lt;/table&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>Error message</p>
  
  <blockquote>
    <p>HTTP Status 500 - Unable to compile class for JSP:  type Exception
    report message Unable to compile class for JSP:  description The
    server encountered an internal error that prevented it from fulfilling
    this request. exception org.apache.jasper.JasperException: Unable to
    compile class for JSP:  An error occurred at line: [14] in the
    generated java file:
    [C:\Users\Vu\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\jpsexcel\org\apache\jsp\index_jsp.java]
    Only a type can be imported. org.apache.poi.hssf.usermodel.HSSFSheet
    resolves to a package</p>
    
    <p>An error occurred at line: [15] in the generated java file:
    [C:\Users\Vu\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\jpsexcel\org\apache\jsp\index_jsp.java]
    Only a type can be imported.
    org.apache.poi.hssf.usermodel.HSSFWorkbook resolves to a package An
    error occurred at line: [16] in the generated java file:
    [C:\Users\Vu\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\jpsexcel\org\apache\jsp\index_jsp.java]
    Only a type can be imported. org.apache.poi.hssf.usermodel.HSSFRow
    resolves to a package An error occurred at line: [17] in the generated
    java file:
    [C:\Users\Vu\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\jpsexcel\org\apache\jsp\index_jsp.java]
    Only a type can be imported. org.apache.poi.hssf.usermodel.HSSFCell
    resolves to a package An error occurred at line: 20 in the jsp file:
    /index.jsp HSSFWorkbook cannot be resolved to a type 17:     if
    (filename != null &amp;&amp; !filename.equals("")) { 18:     try{ 19:<br>
    FileInputStream fs =new FileInputStream(filename); 20:<br>
    HSSFWorkbook wb = new HSSFWorkbook(fs); 21:     for (int k = 0; k &lt;
    wb.getNumberOfSheets(); k++){ 22:     int j=i+1; 23:     HSSFSheet
    sheet = wb.getSheetAt(k); An error occurred at line: 20 in the jsp
    file: /index.jsp HSSFWorkbook cannot be resolved to a type 17:     if
    (filename != null &amp;&amp; !filename.equals("")) { 18:     try{ 19:<br>
    FileInputStream fs =new FileInputStream(filename); 20:<br>
    HSSFWorkbook wb = new HSSFWorkbook(fs); 21:     for (int k = 0; k &lt;
    wb.getNumberOfSheets(); k++){ 22:     int j=i+1; 23:     HSSFSheet
    sheet = wb.getSheetAt(k);</p>
    
    <p>An error occurred at line: 23 in the jsp file: /index.jsp HSSFSheet
    cannot be resolved to a type 20:     HSSFWorkbook wb = new
    HSSFWorkbook(fs); 21:     for (int k = 0; k &lt; wb.getNumberOfSheets();
    k++){ 22:     int j=i+1; 23:     HSSFSheet sheet = wb.getSheetAt(k);
    24:     int rows  = sheet.getPhysicalNumberOfRows(); 25:     for (int
    r = 0; r &lt; rows; r++){ 26:     HSSFRow row   = sheet.getRow(r); An
    error occurred at line: 26 in the jsp file: /index.jsp HSSFRow cannot
    be resolved to a type 23:     HSSFSheet sheet = wb.getSheetAt(k); 24: 
    int rows  = sheet.getPhysicalNumberOfRows(); 25:     for (int r = 0; r
    &lt; rows; r++){ 26:     HSSFRow row   = sheet.getRow(r); 27:     int<br>
    cells = row.getPhysicalNumberOfCells();  28:     out.write("<br>");
    29:     HSSFCell cell1  = row.getCell(a);</p>
    
    <p>An error occurred at line: 29 in the jsp file: /index.jsp HSSFCell
    cannot be resolved to a type 26:     HSSFRow row   = sheet.getRow(r);
    27:     int     cells = row.getPhysicalNumberOfCells();  28:<br>
    out.write("<br>"); 29:     HSSFCell cell1  = row.getCell(a); 30:<br>
    value1 = cell1.getStringCellValue(); 31:       HSSFCell cell2  =
    row.getCell(b); 32:         value2 = cell2.getStringCellValue(); An
    error occurred at line: 31 in the jsp file: /index.jsp HSSFCell cannot
    be resolved to a type 28:     out.write("<br>"); 29:     HSSFCell
    cell1  = row.getCell(a); 30:       value1 =
    cell1.getStringCellValue(); 31:       HSSFCell cell2  =
    row.getCell(b); 32:         value2 = cell2.getStringCellValue(); 33:<br>
    HSSFCell cell3  = row.getCell(c); 34:          value3 =
    cell3.getStringCellValue(); An error occurred at line: 33 in the jsp
    file: /index.jsp HSSFCell cannot be resolved to a type 30:<br>
    value1 = cell1.getStringCellValue(); 31:       HSSFCell cell2  =
    row.getCell(b); 32:         value2 = cell2.getStringCellValue(); 33:<br>
    HSSFCell cell3  = row.getCell(c); 34:          value3 =
    cell3.getStringCellValue(); 35:           HSSFCell cell4  =
    row.getCell(d); 36:           value4 = cell4.getStringCellValue();</p>
    
    <p>An error occurred at line: 35 in the jsp file: /index.jsp HSSFCell
    cannot be resolved to a type 32:         value2 =
    cell2.getStringCellValue(); 33:          HSSFCell cell3  =
    row.getCell(c); 34:          value3 = cell3.getStringCellValue(); 35: 
    HSSFCell cell4  = row.getCell(d); 36:           value4 =
    cell4.getStringCellValue(); 37:     %> 38:<br>
    &lt;%=value1%>&lt;%=value2%>&lt;%=value3%>&lt;%=value4%>
    Stacktrace:
      org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
      org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:198)
      org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:450)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
      org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)</p>
    
    <p>note The full stack trace of the root cause is available in the Apache
    Tomcat/8.0.26 logs.</p>
  </blockquote>