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.