yan0320sd2007-06-09 09:49
我有一段关于session和request的代码应用问题,是这样的,好像是session应用范围的问题,就是调用出了问题,帮忙看一下吧:
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import ="java.sql.*" %>
<%
request.setCharacterEncoding("UTF-8");
String username = request.getParameter("username");
String sql = "select * from liuyanbiao where gst_user ='"+username+"'";
ResultSet rs = guestdb.executeQuery(sql);
rs.last();
int rowCount = rs.getRow();
if(rowCount ==0)
{
out.println("没有该用户的留言!!!");
return ;
}
String strCurPage = request.getParameter("page");
int curPage;
if(strCurPage== null)
curPage = 1;
else
curPage = Integer.parseInt(strCurPage);
int countPerPage = 5;
int pageCount = (rowCount+countPerPage-1)/countPerPage;//总的显示页数
rs.absolute((curPage-1)*countPerPage+1);
if(curPage ==1)//若为于第一页
{
%>
第一页
上一页
<%
}
else
{
%>
第一页
上一页
<%
}
if(curPage == pageCount)//若为于最后一页
{
%>
下一页
最后页
<%
}
else
{
%>
下一页
最后页
<%
}
int i = 0;
while(i
");
out.println("用户名: " +rs.getString("gst_user"));
out.println(" ");
out.println("主题:"+rs.getString("gst_title")+"
");
out.println("内容:"+rs.getString("gst_content")+"
");
Timestamp ts = rs.getTimestamp("gst_time");
long lms = ts.getTime();
Date date = new Date(lms);
Time time = new Time(lms);
out.println("留言时间 :"+date);
out.println(" ");
out.println(time);
out.println(" ");
out.println("用户IP:"+rs.getString("gst_ip")+"
");
i++;
rs.next();
}
rs.close();
%>