这是空指针异常~~看看你那里对象没有new,就调用属性和方法了。
解决方案 »
- 莫名的hibernate数据库链接错误,请高手指点
- java.lang.reflect.InvocationTargetException
- java 实现 文件上传, 重新部署时,文件夹中总出现原来上传的图片
- web开发如何进行调试
- JSP自定义标签问题,急!!!!!!
- 急!在myeclipse反向工程生成SpringDao遇到的问题
- Hibernate 缓存问题
- 服务版的tomcat7如何调参数,Jprofiler如何测试是否内存溢出
- 有学习jsp比较经典的书吗,适合初学者的?
- web网站想做qq登录、新浪微博登录、百度账号登录、人人网登录、登录微博登录
- 请高手帮我看看这是什么错误?郁闷好几天了....
- struts 标签
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="../error/error.jsp"
%>
<!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>
<jsp:useBean id="books" class="BookShop.MyDb" scope="page"/><link rel="stylesheet" type="text/css" href="../css/bs.css"/>
<script language="javascript" src="../css/bs.js"></script>
<%!
String idbook,bookname;
%>
</head>
<body topmargin="0" >
<p> </p>
<table width="646" border="1" align="center" cellpadding="-1" cellspacing="0" bordercolor="#FFFFFF" bordercolorlight="#0066ff" bordercolordark="#FFFFFF" >
<caption>
<div class="two">热点图书</div>
<p></p>
</caption>
<tr>
<td width="149" height="22" align="center">图书编号</td>
<td width="404" align="center">图书名称</td>
<td width="85" align="center">购物车</td>
</tr>
<%
String sqls="SELECT idbook,bookname FROM books WHERE hotdeal=1";
Statement stmt=books.getstmtread();
ResultSet rs=stmt.executeQuery(sqls);
if(!rs.next()){
%>
<tr>
<td height="40" colspan="3" align="center" class="red12">暂无热点图书</td>
</tr>
<%
books.close();
}else{
rs.beforeFirst();
while(rs.next()){
idbook=rs.getString(1);
bookname=rs.getString(2);
idbook=books.outStr(idbook);
bookname=books.outStr(bookname);
%>
<form action="../shop/trade.jsp" method="post">
<tr>
<td height="22" align="center"><%=idbook%></td>
<td align="center"><a href="bookmsg.jsp?idbook=<%=idbook%>"><%=bookname%></a></td>
<td align="center">
<input type="image" src="../image/add.gif" alt="添加购物车" >
<input type="hidden" name="action" value="add">
<input type="hidden" name="id" value="<%=idbook%>"> </td>
</tr>
</form>
<%
}
books.close();
}
%>
</table>
<table width="472" align="center" >
<tr>
<td height="50" valign="bottom" class="red12">
<%
String ip="";
try{
ip=(String)request.getRemoteAddr();
}catch(Exception e){
ip="";
}
ip=books.inStr(ip);
int temp=0,count=0,degree=1;
String sqls1="SELECT visitip,degree FROM visit WHERE visitip='"+ip+"'";
stmt=books.getstmtread();
rs=stmt.executeQuery(sqls1);
if(rs.next()){
degree=rs.getInt(2);
degree++;
books.close();
String sqlu="UPDATE visit SET degree="+degree+" WHERE visitip='"+ip+"'";
Statement stmt1=books.getstmt();
temp=0;
temp=stmt1.executeUpdate(sqlu);
}else{
books.close();
String sqli="INSERT INTO visit(visitip) VALUES('"+ip+"')";
Statement stmt2=books.getstmt();
temp=0;
temp=stmt2.executeUpdate(sqli);
}
books.close();
String sqls2="SELECT COUNT(*) FROM visit";
stmt=books.getstmtread();
rs=stmt.executeQuery(sqls2);
if(rs.next()){
count=rs.getInt(1);
}
books.close();
pageContext.removeAttribute("books");
out.print("欢迎来自["+ip+"]的朋友"+"<br>");
out.print("这是您第["+degree+"]次来访"+"<br>");
out.print("曾有"+count+"位朋友来访");
%>
</td>
</tr>
</table>
</body>
</html>