回 帖 发 新 帖 刷新版面

主题:高手们请这边看,帮我解决下这个难题啊,很急啊,谢谢啊

这是我的browse.jsp文件
<%@ page import ="java.sql.*"%>
<%@ page import ="count.SessionListener"%>
<%@ page language ="java"%>
<%
if(session.getAttribute("username")==null)
 {
   response.sendRedirect();
 }
%>
  <jsp:useBean id ="mybook" scope ="page" class="book.Bk"/>
<%
int PageSize =8;
int ShowPage =1;
int RowCount =0;
int PageCount=0;
ResultSet rs =mybook.executeQuery("SELECT * FROM books");
rs.last();
RowCount=rs.getRow();
PageCount =((RowCount % PageSize)==0?(RowCount/PageSize):(RowCount/PageSize)+1);
%>
<html>
<head>
<title>网上平价书店</title>
</head>
<body>
<center>
<font size =5 color =blue>Welcome to the on_line bookstore</font>
</center>
<center><p>在线人数:<%=SessionListener.getCount()%></p>
</center>
<br>
<hr>
<br>
<center>
<%
String ToPage=request.getParameter("ToPage");
if(ToPage!=null)
{
  ShowPage =Integer.parseInt(ToPage);
  if(ShowPage>PageCount)
  {
     ShowPage=PageCount;
     }
  elseif(ShowPage<=0)
    {
     ShowPage =1;
     }
}
rs.absolute((ShowPage-1)*PageSize +1);
%>
<h3>当前在第<font size =4 color =red>
<%=ShowPage %></font>页,共
<font size =4 color =red>
<%=PageCount %></font>页,</h3>
<br>
<table border="1" width ="100%">
 <tr>
   <td width ="33%"> 书名</td>
   <td width ="33%"> 作者</td>
   <td width ="10%"> 价格</td>
   <td width ="24%"> 购书</td>
 </tr>
<%
  int i=0;
  while(rs.next()){
  i=i+1;
%>
<tr>
   <td width ="35%"><%=rs.getString("name")%></td>
   <td width ="35%"><%=rs.getString("author")%></td>
   <td width ="10%"><%=(rs.getInt("price"))%></td>
   <td width ="22%"><a href ="cart.jsp?book_id=<%=rs.getInt("name")%>">选购此书</a></td>
</tr>
<%
if(i==PageSize)
{
   break;
}
%>
<%
}
rs.close();
%>
</table>
<table>
<tr valign=baseline align=center>
<%
if(ShowPage!=1)
{
%>
<td width=150>
<a href =browse.jsp? ToPage=<%=ShowPage-1 %>>到上一页</a>
</td>
<%
}
if(ShowPage!=PageCount)
{
%>
<td width =150>
<a href=browse.jsp? ToPage=<%=ShowPage+1 %>>到下一页</a>
</td>
<td width =150>
<a href =browse.jsp? ToPage=<%=PageCount %>>到最后一页</a>
</td>
<%
}
%>
<td width =150>
<form action =browse.jsp.jsp method =POST>

<INPUT type ="text" name =ToPage style ="height:25px;width:40px">
value=<%=ShowPage%>>页
</form></td></tr>
</table>
</center>
</body>
</html>

///////////////////////////////////////
错误提示;

 The server encountered an internal error () that prevented it from fulfilling this request.

exception 

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 36 in the jsp file: /browse.jsp
Generated servlet error:
D:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\webbook\org\apache\jsp\browse_jsp.java:103: 需要 ';'
    {
    ^
1 错误



    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
    org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:670)
    org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:637)
    org.apache.jsp.login_005fconfirm_jsp._jspService(login_005fconfirm_jsp.java:73)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.

我真得不知道哪里少分号(;)了,






























[em10][em10]

回复列表 (共3个回复)

沙发

<%
String ToPage=request.getParameter("ToPage");
if(ToPage!=null)
{
  ShowPage =Integer.parseInt(ToPage);
  if(ShowPage>PageCount)
  {
     ShowPage=PageCount;
     }
  elseif(ShowPage<=0)
    {
     ShowPage =1;
     }
}
rs.absolute((ShowPage-1)*PageSize +1);
%>
应该是这部分出问题了,好象你的大于号跟<%这个配对了!!!

板凳


大于号前面要有%才会匹配啊, 怎么改啊

3 楼


刚才发现错误了,是elseif连在一起了,中间有空格,但后来运行时又出现另外的错误
javax.servlet.ServletException: No data found
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
    org.apache.jsp.browse_jsp._jspService(browse_jsp.java:245)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:670)
    org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:637)
    org.apache.jsp.login_005fconfirm_jsp._jspService(login_005fconfirm_jsp.java:73)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause 

java.sql.SQLException: No data found
    sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7139)
    sun.jdbc.odbc.JdbcOdbc.SQLGetDataInteger(JdbcOdbc.java:3812)
    sun.jdbc.odbc.JdbcOdbcResultSet.getDataInteger(JdbcOdbcResultSet.java:5639)
    sun.jdbc.odbc.JdbcOdbcResultSet.getInt(JdbcOdbcResultSet.java:582)
    sun.jdbc.odbc.JdbcOdbcResultSet.getInt(JdbcOdbcResultSet.java:600)
    org.apache.jsp.browse_jsp._jspService(browse_jsp.java:145)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:670)
    org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:637)
    org.apache.jsp.login_005fconfirm_jsp._jspService(login_005fconfirm_jsp.java:73)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

我来回复

您尚未登录,请登录后再回复。点此登录或注册