• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
  • Tim Holloway
  • Carey Brown
  • salvin francis

Unable to compile class for JSP

Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,everyone.I met a problem when I try to run my jsp.
I have written a class called bookdetail in my exe package(i am using eclipse)and when i have imported in the jsp page and try to write this:
bookdetail mybd=new bookdetail();
well,eclipse told me that "booktail can not be resolve to a type"
and if I compile the project ,tomcat told me

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 35 in the jsp file: /booklist.jsp
Generated servlet error:
bookdetail mybd=new bookdetail();

An error occurred at line: 35 in the jsp file: /booklist.jsp
Generated servlet error:

Here's my code bookstore.jsp

<%@ page pageEncoding="gb2312"%>
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page language="java" import="java.util.*" %>
<%@ page language="java" import="exe.bookdetail.*" %>

String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<jsp:useBean id="mybs" class="exe.bookstore" scope="session"/>

<base href="<%=basePath%>">

<title>My JSP 'booklist.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<link rel="stylesheet" type="text/css" href="styles.css">


for(int i=1;i<=mybs.getrecordscount();i++)
bookdetail mybd=new bookdetail();


and bookdetail.java
package exe;

import java.sql.*;

public class bookdetail {
private String bookId=null;
private String title=null;
private String name=null;
private float price =0.0F;
private boolean onSale=false;
private int year=0;
private String description =null;
private int inventory=0;

public bookdetail(ResultSet rs)
}catch(Exception ex){}

public String getBookId() {
return bookId;

public void setBookId(String bookId) {
this.bookId = bookId;

public String getDescription() {
return description;

public void setDescription(String description) {
this.description = description;

public int getInventory() {
return inventory;

public void setInventory(int inventory) {
this.inventory = inventory;

public String getName() {
return name;

public void setName(String name) {
this.name = name;

public boolean isOnSale() {
return onSale;

public void setOnSale(boolean onSale) {
this.onSale = onSale;

public float getPrice() {
return price;

public void setPrice(float price) {
this.price = price;

public String getTitle() {
return title;

public void setTitle(String title) {
this.title = title;

public int getYear() {
return year;

public void setYear(int year) {
this.year = year;


Many thanks to anyone who can helps.
John Hood.
John Hood
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey,the problem was solved.
I made a mistake in importing packages.
the right statement shall be
<%@ page language="java" import="exe.*" %>
<%@ page language="java" import="exe.bookdetail.*" %>

and why cannot compile??!!
The disk space is full,After the disk was cleaned,it runs well.
You know it is dark times when the trees riot. I think this tiny ad is their leader:
Enterprise-grade Excel API for Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!