<%@ page language="java" contentType="text/html;charset=GB2312"%>
<%@ page import="java.sql.*"%>
<%@ page import="com.firm.Firm"%><html>
<head>
<title>Insert title here</title>
</head>
<body>
<jsp:useBean id="addBean" scope="page" class="com.firm.Firm "/>
<%
String name = new String(request.getParameter("name").getBytes("8859_1"));
String emote = new String(request.getParameter("emote").getBytes("8859_1"));
String content = new String(request.getParameter("content").getBytes("8859_1"));
String strsql = "insert into guestbook (name,emote,content) values ('" + name + "','" + emote +"','" + content + "')";
addBean.executeUpdate(strsql);
out.print("您的留言已经保存到数据库中,谢谢!");
%>
</body>
</html>老是提示说org.apache.jasper.JasperException: /ok_guest.jsp(18,0) The value for the useBean class attribute com.firm.Firm  is invalid.而且Firm.class也是放在 WEB-INF\classes\com\firm 下的

解决方案 »

  1.   

    package com.firm;import java.sql.*;
    /**
     * @author Administrator
     *
     * TODO 要更改此生成的类型注释的模板,请转至
     * 窗口 - 首选项 - Java - 代码样式 - 代码模板
     */
    public class Firm {
    String sDBDriver = "sun.jdbc.odbc,JdbcOdbcDriver";
    String sConnstr = "jdbc:odbc:buxj";
    private Connection conn = null;
    private Statement stmt = null;
    ResultSet rs= null;
    //注册驱动程序
    public Firm()
    {
    try
    {
    Class.forName(sDBDriver);
    }
    catch(java.lang.ClassNotFoundException e)
    {
    System.err.println("Firm():"+ e.getMessage());
    }
    }
    //建立数据库连接,定义数据查询
    public ResultSet executeQuery( String sql)
    {
    rs = null;
    try
    {
    conn = DriverManager.getConnection(sConnstr);
    stmt = conn.createStatement();
    rs = stmt.executeQuery(sql);
    }
    catch(SQLException ex)
    {
    System.err.println("aq.executeQuery:" + ex.getMessage());
    }
    return rs;
    }
    public void executeUpdate(String sql)
    {
    stmt = null;
    rs = null;
    try
    {
    conn = DriverManager.getConnection(sConnstr);
    stmt = conn.createStatement();
    stmt.executeUpdate(sql);
    stmt.close();
    conn.close();
    }
    catch(SQLException ex)
    {
    System.err.println("aq.executeQuery:" + ex.getMessage());
    }
    }
    public void closeStmt()
    {
    try
    {
    stmt.close();
    }
    catch(SQLException e)
    {
    e.printStackTrace();
    }
    }
    public void closeConn()
    {
    try
    {
    conn.close();
    }
    catch(SQLException e)
    {
    e.printStackTrace();
    }
    }

    }
      

  2.   

    你引这个类包时能不能改成com.firm.*?改完了以后试试