• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not able to complie JSP file.

 
prakash chauhan
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have the following code in my jsp , when i try to execute it , i get an exception in tomcat that it was not able to compile it as
it was not able to resolve the class name or Type:
HSSFWorkbook ,HSSFRow , HSSFCell and POIFSFileSystem
I have these files in my build path (class path) and i can execute the code below (exactly same) if i execute it in a java class instead of jsp.
it runs and gives me the result as well, but in scriptlet it does not.
what am i doing wrong?
-Thanks.

------------------------------------------------------------
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.io.*,org.apache.poi.hssf.usermodel.*,org.apache.poi.poifs.filesystem.*" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

<%
FileInputStream fileIn = null;
FileOutputStream fileOut = null;

try
{
fileIn = new FileInputStream("c:\\MYEXCEL.xls");
org.apache.poi.poifs.filesystem.POIFSFileSystem fs = new POIFSFileSystem(fileIn);
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.getSheetAt(0);
int NO_OF_ROWS=sheet.getPhysicalNumberOfRows();

HSSFRow row ;
HSSFCell cell ;

for(int i=1;i<NO_OF_ROWS;i++){
row = sheet.getRow(i);
for(int j=0;j<=3;j++){
cell=row.getCell((short)j);
if(j==0){
out.print("Name: "+ cell.getRichStringCellValue()+ " ");
continue;
}

out.print(cell.getNumericCellValue()+" ");
}
out.println("\n");
}




// Write the output to a file

}
finally
{
if (fileOut != null)
fileOut.close();
if (fileIn != null)
fileIn.close();
}
%>


</body>
</html>
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The POI jar file needs to be in the WEB-INF/lib directory of your web application.
 
prakash chauhan
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks it worked.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic