[求助]继续求助,关于分页的诚心求教!

IKARI_DALI 2006-03-03 05:15:51
这次出现报错了:
type Exception report

message

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

exception

org.apache.jasper.JasperException: /index.jsp(36,0) Unterminated <%@ include tag
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:134)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:511)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1539)
org.apache.jasper.compiler.Parser.parse(Parser.java:126)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:220)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:203)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:490)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:471)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:459)
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)
servlet.TopServlet.doGet(TopServlet.java:32)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:34)



说是标签没有结束,但是我怎么找也没发现错误,还是把代码贴出来,大家帮我看看吧~谢谢啦!^_^

index.jsp
<%@page contentType="text/html;charset=gbk" language="java" import="java.sql.*,bean.*,servlet.*"%>
<%@include file="manager\getuser.jsp"%>
<jsp:useBean id="pageCtl" class="bean.PageBean" scope="request"/>
<html><body>
<p>
<%
try
{
out.print("欢迎你"+ub.getUsername());%>
<a href="addcon.jsp"> 点击发表新贴</a>
<a href="logout.jsp">注销</a></p><%
}
catch(Exception e)
{
%>
你还没有登录,请先<a href="alogin.jsp">登录</a>,
如果没有注册,请<a href="reg.jsp">注册</a><%
}
%>
<table border=1>
<%java.util.Vector v=pageCtl.getResult();
java.util.Enumeration e=v.elements();

while(e.hasMoreElements())
{
Object[] obj=(Object[])e.nextElement();%>
<tr>
<td><%=obj[0]%></td>
<td><%=obj[1]%></td>
<td><%=obj[2]%></td>
</tr><%}%>
</table>
<%
if(pageCtl.maxPage!=1)%>
<form name="PageForm" action="/topservlet" method="post">
<%@include file="page.jsp">
</form>
<%}%>
</body></html>



还有其中嵌套的page.jsp(getuser.jsp应该没错,因为在别的页面上都通过了)
<script language="JavaScript">

<!--
function Jumping(){
document.PageForm.submit();
return ;
}

function gotoPage(pageN){
document.PageForm.jumpPage.value = pageN;
document.PageForm.submit();
return ;
}

-->
</script>

每页<%=pageCtl.rowsPerPage%>行
共<%=pageCtl.maxCout%>行
第<%=pageCtl.curPage%>页
共<%=pageCtl.maxPage%>页
<%if(pageCtl.curPage==1){ out.print(" 首页 上一页"); }else{ %>
<A HREF="javascript:gotoPage(1)">首页</A>
<A HREF="javascript:gotoPage(<%=pageCtl.curPage-1%>)">上一页</A>
<%}
if(pageCtl.curPage==pageCtl.maxPage){ out.print("下一页 尾页"); }else{ %>
<A HREF="javascript:gotoPage(<%=pageCtl.curPage+1%>)">下一页</A>
<A HREF="javascript:gotoPage(<%=pageCtl.maxPage%>)">尾页</A>
<%}%>
转到第<SELECT name="jumpPage" onchange="Jumping()">
<% for(int i=1;i<=pageCtl.maxPage;i++) {
if (i== pageCtl.curPage){
%>
<OPTION selected value=<%=i%>><%=i%></OPTION>
<%}else{%>
<OPTION value=<%=i%>><%=i%></OPTION>
<%}}%>
</SELECT>页




PageBean.java
package bean;

import bean.*;
import java.util.Vector;

public class PageBean
{
public int curPage;//当前第几页
public int maxPage;//一共几页
public int maxCout;//一共几行
public int pageCout=10;//每行几页
public java.util.Vector data;

public PageBean()
{
}

public void Cmaxpage()
{
if(this.maxCout%this.pageCout==0)
{
this.maxPage=this.maxCout/this.pageCout;
}
else
{
this.maxPage=this.maxCout/this.pageCout+1;
}
}

public Vector getResult()
{
return this.data;
}

public PageBean(PBusinessBean pageC)throws Exception
{
this.maxCout=pageC.getAvailableCount();
this.data=pageC.getResult();
this.Cmaxpage();
}
}
...全文
60 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
koma_wind 2006-03-04
发错了
回复
koma_wind 2006-03-04
要学会自己学习
/*
* Created on 2006-3-4
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package com.easydone.cn.tools.utils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Date;

/**
* @author Administrator
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class MakeHtml {
private static long star = 0;
private static long end = 0;
private static long ttime = 0;

//返回html代码
public static String getHtmlCode(String httpUrl){
Date before = new Date();
star = before.getTime();
String htmlCode = "";
try {
InputStream in;
URL url = new java.net.URL(httpUrl);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("User-Agent","Mozilla/4.0");
connection.connect();
in = connection.getInputStream();
java.io.BufferedReader breader = new BufferedReader(new InputStreamReader(in , "GBK"));
String currentLine;
while((currentLine=breader.readLine())!=null){
htmlCode+=currentLine;
}
} catch (Exception e) {
e.printStackTrace();
}finally{
Date after = new Date();
end = after.getTime();
ttime = end-star ;
System.out.println("执行时间:"+ttime +"秒");
}
return htmlCode;
}
//存储文件
public static synchronized void writeHtml(String filePath,String info,String flag) {

PrintWriter pw = null;
try {
File writeFile = new File(filePath);
boolean isExit = writeFile.exists();
if (isExit != true) {
writeFile.createNewFile();
} else {
if (!flag.equals("NO")) {
writeFile.delete();
writeFile.createNewFile();
}
}
pw = new PrintWriter(new FileOutputStream(filePath, true));
pw.println(info);
pw.close();
} catch (Exception ex) {
System.out.println(ex.getMessage());
}finally{
pw.close();
}
}

public static void main(String[] args) {
String url = "http://www.easydone.cn/index.htm";
writeHtml("c:/demo.htm",getHtmlCode(url),"NO");
}
}
回复
northwolf_sky 2006-03-03
很简单嘛调试呀
回复
IKARI_DALI 2006-03-03
PBusinessBean.java
package bean;

import java.sql.*;
import bean.*;
import java.util.*;


public class PBusinessBean
{
private Connection conn=null;
private ResultSet res=null;
private java.sql.PreparedStatement prepar=null;
private java.sql.CallableStatement proc=null;
Vector v;

public PBusinessBean()throws Exception//connection
{
String CLASSFORNAME="com.mysql.jdbc.Driver";
String URL="jdbc:mysql://localhost:3306/ikaribbs?useUnicode=true&characterEncoding=GBK";
String USER="ikaridali";
String PW="TRSTTT";
Class.forName (CLASSFORNAME);
conn=java.sql.DriverManager.getConnection(URL,USER,PW);
v=new Vector();
}

public int getAvailableCount()//select the max count in table
{
int ret=0;
String sql="select count(*) from topic";
try
{
PreparedStatement prepar=conn.prepareStatement(sql);
ResultSet res=prepar.executeQuery();
while(res.next());
{
ret = res.getInt(1);
}
}
catch(Exception e)
{
e.printStackTrace();
}
return ret;
}

public PageBean listData(String page)throws Exception//for topic
{
try
{
PageBean pageBean=new PageBean(this);
int pageN=Integer.parseInt(page);
String sql="select top"+pageN*pageBean.pageCout+"* from topic order by crTime";
PreparedStatement prepar=conn.prepareStatement(sql);
res=prepar.executeQuery();
int i=0;
while(res.next())
{
if(i>(pageN-1)*pageBean.pageCout-1)
{
Object[] obj=new Object[6];
obj[0]=res.getString("title");
obj[1]=res.getString("creater");
obj[2]=res.getString("article");
//obj[3]=res.getString("crTime");
//obj[4]=new Integer(res.getInt("re"));
//obj[5]=new Integer(res.getInt("cli"));
//obj[6]=res.getString("lstAnswer");
//obj[7]=res.getDate("lstRet");
v.add(obj);
}
i++;
}
res.close();
prepar.close();
pageBean.curPage=pageN;
pageBean.data=v;
return pageBean;
}
catch(Exception e)
{
e.printStackTrace();
throw e;
}
}

public Vector getResult()throws Exception
{
return v;
}
}




TopServlet.java
package servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import bean.*;

public class TopServlet extends HttpServlet
{
private static final String CONTENT_TYPE="text/html;charset=GBK";
public void init() throws ServletException
{}

public void doGet(HttpServletRequest requ,HttpServletResponse resp) throws ServletException,IOException
{
resp.setContentType("text/html; charset=GBK");
requ.setCharacterEncoding("GBK");
resp.setCharacterEncoding("GBK");
//PrintWriter out=response.getWriter();
try
{
PBusinessBean pageC=new PBusinessBean();
PageBean pageCtl=pageC.listData((String)requ.getParameter("jumpPage"));
requ.setAttribute("pageCtl",pageCtl);
}
catch(Exception e)
{
e.printStackTrace();
}
javax.servlet.RequestDispatcher dis=requ.getRequestDispatcher("/index.jsp");
dis.forward(requ,resp);
}

public void doPost(HttpServletRequest requ, HttpServletResponse resp)
throws ServletException, IOException
{
doGet(requ,resp);
}

public void destroy()
{
}
}

很不好意思又是这么大一驼......我的论坛就剩下这个了,说实话分页在逻辑上我也不是很清楚,最好有谁能帮我解释一下(总感觉"第几页"这个值获得的有点像先有鸡还是先有蛋一样奇怪......),不过最主要的是能帮我解答这个错误,这对我来说实在是太重要啦!大哥大姐一定要帮我~实在谢谢~~
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2006-03-03 05:15
社区公告
暂无公告