*
The moose likes JSP and the fly likes Unable to compile class for JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Unable to compile class for JSP" Watch "Unable to compile class for JSP" New topic
Author

Unable to compile class for JSP

John Hood
Greenhorn

Joined: Aug 06, 2006
Posts: 6
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:
org.apache.jsp.booklist_jsp
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"%>
<%request.setCharacterEncoding("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">
<html>
<jsp:useBean id="mybs" class="exe.bookstore" scope="session"/>

<head>
<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">
-->
</head>

<body>
<%

for(int i=1;i<=mybs.getrecordscount();i++)
{
bookdetail mybd=new bookdetail();
mybd=mybs.getrecordvalue(String.valueOf(i));
out.println(mybd.getBookId());
out.println(mybd.getDescription());
}

%>
</body>
</html>

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)
{
try{
rs.next();
bookId=rs.getString(1);
title=rs.getString(2);
name=rs.getString(3);
price=rs.getFloat(4);
onSale=rs.getBoolean(5);
year=rs.getInt(6);
description=rs.getString(7);
inventory=rs.getInt(8);
}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
Greenhorn

Joined: Aug 06, 2006
Posts: 6
hey,the problem was solved.
I made a mistake in importing packages.
the right statement shall be
<%@ page language="java" import="exe.*" %>
not
<%@ page language="java" import="exe.bookdetail.*" %>

and why cannot compile??!!
The disk space is full,After the disk was cleaned,it runs well.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to compile class for JSP
 
Similar Threads
What is the problem with this code!!!
f:selectItems can't set value
Problems with bean example
Jsp got null,false,0
JSP Not Reading Arraylist