javabean
package com.fox_ice.util;
import javax.naming.*;
import javax.sql.*;
import java.sql.*;
import java.io.Serializable;public class bookstoredb implements Serializable
{ private static final long serialVersionUID = 4554678743229927181L;
private DataSource ds=null;
public bookstoredb() //throws NamingException
{
try
{
Context ctx=new InitialContext();
ds=(DataSource)ctx.lookup("java:comp/env/jdbc/boostore");
}
catch(NamingException ne)
{
ne.printStackTrace();
}
}
public Connection getConnection() throws SQLException
{
return ds.getConnection();
}
public void closeConnection(Connection conn) throws SQLException
{
if(conn!=null)
{
try
{
conn.close();
conn=null;
}
catch(SQLException se)
{
se.printStackTrace();
}
}
}
public void closeStatement(Statement stmt) throws SQLException
{
if(stmt!=null)
{
try
{
stmt.close();
stmt=null;
}
catch(SQLException se)
{
se.printStackTrace();
}
}
}
public void closePreparedStatement(PreparedStatement pstmt) throws SQLException
{
if(pstmt!=null)
{
try
{
pstmt.close();
pstmt=null;
}
catch(SQLException se)
{
se.printStackTrace();
}
}
}
public void closeResultSet(ResultSet rs) throws SQLException
{
if(rs!=null)
{
try
{
rs.close();
rs=null;
}
catch(SQLException se)
{
se.printStackTrace();
}
}
}
}
regchk.jsp
<%@ page language="java" contentType="text/html; charset=gb2312"%>
<%@ page import="java.sql.*,javax.sql.*,javax.naming.*" %>
<jsp:useBean id="bookstore" scope="session" class="com.fox_ice.util.bookstoredb"/><html>
<head>
<title>验证页面</title>
</head>
<body>
<%
request.setCharacter("gb2312");
String u_name=request.getParameter("u_name");
String u_pwd=request.getParameter("u_pwd");
String u_pwd1=request.getParameter("u_pwd1");
String u_sex=request.getParameter("u_sex");
u_name=u_name.trim();
u_pwd=u_pwd.trim();
u_pwd1=u_pwd1.trim();
u_sex=u_sex.trim();
if(u_name==null)
{
out.println("请输入姓名");
//response.sendRedirect("index.jsp");
out.println("请重新<a href='reg.jsp'>注册</a>");
return;
}
if(u_pwd!=u_pwd1)
{
out.println("两次输入密码不一样");
//response.sendRedirect("index.jsp");
out.println("请重新<a href='reg.jsp'>注册</a>");
return;
}
Connection conn=bookstore.getConnection();
PreparedStatement pstmt=conn.prepareStatement("insert into user(u_name,sex,u_pwd) values (?,?,?)");
pstmt.setString(1,u_name);
pstmt.setString(2,u_pwd);
pstmt.setString(3,u_sex);
pstmt.executeUpdate();
bookstore.closeConnection(conn);
bookstore.closePreparedStatement(pstmt);
response.sendRedirect("index.jsp");
%>
reg.jsp
<%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>注册</title></head>
<body>
<form action="regchk.jsp" method="post" name="theForm" >
<table cellspacing=0 cellpadding=0 align=center>
<tr>
<td>姓名</td>
<td><input type="text" name="u_name"></td>
</tr>
<tr>
<td>密码</td>
<td><input type="password" name="u_pwd"></td>
</tr>
<tr>
<td>请再输入一次</td>
<td><input type="password" name="u_pwd1"></td>
</tr>
<tr>
<td>性别</td>
<td>
<input type="radio" name="u_sex" value="男" checked>男
<input type="radio" name="u_sex"value="女" >女
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="提交" name="btnSubmit" >
<input type="reset" value="重写">
<input type="hidden" value=<%= new java.util.Date() %>>
</td>
</tr>
</table>
</form>
</body>
</html>
</body>
</html>出现错误
The value for the useBean class attribute com.fox_ice.util.bookstoredb is invalid
各位老大帮帮我啊
解决方案 »
- 求做微博代码
- 怎么解决乱码啊
- 有没有人遇到我这样的问题帮助解决下!
- 如何控制fckeditor工具栏里面东西的多少?
- 如何利用servlet实现动态资源连接(隐藏真实资源地址)?
- JSP+Bean里<jsp:getProperty>问题
- J2EE体系复杂,我们在公司里会用到什么呢(没分了, 不好意思)
- 关于urlrewrite转发问题!在线等!!!
- The value for the useBean class attribute ckstudio.db.faq is invalid.
- 菜鸟问菜问题?
- jsp中include.inc的作用是什么?
- struts2上传文件的中文问题。急急。急。都来看看。
1. 在编译 JSP 时(不是运行时),指定的 Bean 类没找到
2. Bean 虽然找到了,但是它不是 public 的,或者找到的 class 文件是 interface 或抽象类
3. Bean 类中没有 public 的默认构建函数
看看是不是包路径有问题,路径下有没有这个类,或者重新编译一下项目试试