myEclipse报错异常: Servlet.service() for servlet jsp threw exception求解决

wallacefw 发布于 2013/04/08 19:59
阅读 7K+
收藏 0
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  </head>
  <body>
  	<jsp:include page="head.jsp">
  	
	<table border="3" align="center" width="80%">
		<caption><h1>论坛——主题</h1></caption>
		<tr>
			<th>名称</th>
			<th>作者</th>
			<th>回贴数</th>
			<th>时间</th>
		</tr>
		<c:forEach var="topic" items="${listTopic}">
			<tr>
				<td>${topic.name}</td>
				<td>${topic.author}</td>
				<td>xxxx</td>
				<td>${topic.time}</td>
			</tr>
		</c:forEach>
	</table>  
	<jsp:include page="foot.jsp"/>
  </body>
</html>
package cn.itcast.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.sun.org.apache.commons.beanutils.BeanUtils;
import cn.itcast.exception.UserNullException;
import cn.itcast.exception.UserOrPasswordNotFoundException;
import cn.itcast.exception.UsernameOrPasswordException;
import cn.itcast.exception.UsernameOrPasswordExceptionException;
import cn.itcast.javabean.Topic;
import cn.itcast.javabean.Type;
import cn.itcast.javabean.User;
import cn.itcast.serice.BbsService;
import cn.itcast.serice.LoginToTest;
import cn.itcast.serice.RegisterToTest;

public class BbsServlet extends HttpServlet {

	public void init() throws ServletException {
		List<String> usernameList = new ArrayList<String>();
		ServletContext context = this.getServletContext();
		context.setAttribute("usernameList", usernameList);
	}

public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doGet(request, response);
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// 1.在index.jsp中获取参数
		String method = request.getParameter("method");
if ("findTopic".equals(method)) {
				this.findTopic(request, response);
			} 

// 根据板块查询对应的topic.JSP(主题)
	private void findTopic(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// 获取板块编号
		String id = request.getParameter("id");
		// 1.检测是否获取得到
		// System.out.println(id);//获取成功显示:1
		int Id = Integer.parseInt(id);
		// 2.检测是否获取得到
		//System.out.println("_____Id" + Id);//这里也没问题
		// 调用业务层
		BbsService service = new BbsService();
		// 2-1.检测是否获取得到
		//System.out.print("aaaaaaaaaaaaaaaaaaaa");这里没什么问题
		try {
			//3.检测到这里
			//System.out.println("aaaaa" + Id);//这里没问题
			List<Topic> listTopic = service.findTopic(Id);
			/*//5.检测到这里
			System.out.println("____--------______aaaaaaaaa");
			System.out.println("listTopic"+listTopic.size());*/
			//这里没问题
			request.setAttribute("listTopic", listTopic);
			request.getRequestDispatcher("/WEB-INF/jsp/listAllTopic.jsp")
					.forward(request, response);

		} catch (Exception e) {
			// 如果输入错误,则转发到message.JSP页面中
			e.printStackTrace();
			request.setAttribute("message", "板块号码输入错误");
			// 发送
			request.getRequestDispatcher("/WEB-INF/jsp/message.jsp").forward(
					request, response);
		}

	}
}
package cn.itcast.serice;

import java.util.List;
import org.junit.Test;
import cn.itcast.bbs.exception.NoUserException;
import cn.itcast.dao.inte.BBSDao;
import cn.itcast.dao.inte.InteTypeDao;
import cn.itcast.exception.FindTypeException;
import cn.itcast.exception.NoFoundIdException;
import cn.itcast.exception.UserNullException;
import cn.itcast.exception.UserOrPasswordNotFoundException;
import cn.itcast.exception.UserPassWordNullException;
import cn.itcast.javabean.Topic;
import cn.itcast.javabean.Type;
import cn.itcast.javabean.User;
import cn.itcast.tool.MD5Tool;

public class BbsService {
	private InteTypeDao inteTypeDao = new BBSDao();


	//对Topic页面进行调用数据,主要两方面,先是在serlvet层获取id,然后是在dao层获取数据
	public List<Topic> findTopic(Integer id) throws Exception{
		//检测到这里没问题
		//System.out.print("lllllllll"+id);
		if(id==null){
			throw new NoFoundIdException();
		}
		//如果id正确,则由Servlet传送数据到Serice的这里,查看Servlet的方法
		try {
			//4检测
			//System.out.print("--------"+inteTypeDao.findTopic(id).toString());没问题
			return inteTypeDao.findTopic(id);
		} catch (Exception e) {
			throw e;
		}
	}
}
package cn.itcast.dao.inte;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.junit.Test;
import cn.itcast.javabean.Topic;
import cn.itcast.javabean.Type;
import cn.itcast.javabean.User;
import cn.itcast.tool.DBUtil;

//dao层数据
public class BBSDao implements InteTypeDao {
	//对topic.sql的文件进行获取,于它有关联的type_id,
	@Test
	public List<Topic> findTopic(Integer id) throws Exception{
		
		List<Topic> listTopic = new ArrayList<Topic>();
		QueryRunner runner = new QueryRunner(DBUtil.getDataSource());
		String sql ="select * from topic where type_id =?";
		Object[] ob ={ id };
		listTopic = runner.query(sql, new BeanListHandler<Topic>(Topic.class), ob);
		return listTopic;
	}
	
}

各位高手本人写的一个项目中,在运行时候,出现异常,由于本人是刚刚学习javaee,我已经测试过,排除在数据库(MySql)、dao层、service层的错误。而在servlet层的测试中我已经检测到没什么问题了。但是还是出现这个异常。希望各位能够帮我解答,这个错是怎么更正。 如果要拿我的代码查看错误,我很欢迎。希望各位高手帮帮忙!

Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: /WEB-INF/jsp/listAllTopic.jsp (line: 10, column: 1) Expecting "jsp:param" standard action with "name" and "value" attributes
 at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
 at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:408)
 at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:89)
 at org.apache.jasper.compiler.Parser.parseParam(Parser.java:825)
 at org.apache.jasper.compiler.Parser.parseBody(Parser.java:1672)
 at org.apache.jasper.compiler.Parser.parseOptionalBody(Parser.java:1002)
 at org.apache.jasper.compiler.Parser.parseInclude(Parser.java:854)
 at org.apache.jasper.compiler.Parser.parseStandardAction(Parser.java:1116)
 at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1451)
 at org.apache.jasper.compiler.Parser.parse(Parser.java:138)
 at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242)
 at org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
 at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
 at org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
 at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
 at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
 at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
 at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
 at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
 at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
 at cn.itcast.servlet.BbsServlet.findTopic(BbsServlet.java:241)
 at cn.itcast.servlet.BbsServlet.doGet(BbsServlet.java:66)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at cn.itcast.fielter.EcondingFilter.doFilter(EcondingFilter.java:29)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
 at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
 at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1813)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
 at java.lang.Thread.run(Thread.java:722)
org.apache.jasper.JasperException: /WEB-INF/jsp/listAllTopic.jsp (line: 10, column: 1) Expecting "jsp:param" standard action with "name" and "value" attributes
 at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
 at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:408)
 at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:89)
 at org.apache.jasper.compiler.Parser.parseParam(Parser.java:825)
 at org.apache.jasper.compiler.Parser.parseBody(Parser.java:1672)

 at org.apache.jasper.compiler.Parser.parseOptionalBody(Parser.java:1002)
 at org.apache.jasper.compiler.Parser.parseInclude(Parser.java:854)
 at org.apache.jasper.compiler.Parser.parseStandardAction(Parser.java:1116)
 at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1451)
 at org.apache.jasper.compiler.Parser.parse(Parser.java:138)

 at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242)
 at org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
 at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
 at org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
 at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)

 at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
 at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
 at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
 at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
 at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
 at cn.itcast.servlet.BbsServlet.findTopic(BbsServlet.java:241)
 at cn.itcast.servlet.BbsServlet.doGet(BbsServlet.java:66)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at cn.itcast.fielter.EcondingFilter.doFilter(EcondingFilter.java:29)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
 at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
 at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1813)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
 at java.lang.Thread.run(Thread.java:722)

 

加载中
0
逝水fox
逝水fox
什么文件的第几行出错 原因是什么明明写的很清楚 为什么贴了那么多 就不能好好看看内容呢...
0
wallacefw
wallacefw

就是根据所说的去看,但是看会servlet层,我是没错的。而且还检测了,所传送的集合的size(),也不为空。所以我真是不知道哪里错了

 

0
随影求是
随影求是

很显然是/WEB-INF/jsp/listAllTopic.jsp这个页面报错了,根据“Expecting "jsp:param" standard action with "name" and "value" attributes”这个错误推断使用了<jsp:include..>标签,jsp:include这个标签一般只能包含<jsp:param/>标签,如果还包含其他标签就会报上面的错误。

以上纯属猜测,没有见到jsp页面源码,无法仔细分析。

wallacefw
wallacefw
我现在已经公布了码源了
0
wallacefw
wallacefw

引用来自“随影求是”的答案

很显然是/WEB-INF/jsp/listAllTopic.jsp这个页面报错了,根据“Expecting "jsp:param" standard action with "name" and "value" attributes”这个错误推断使用了<jsp:include..>标签,jsp:include这个标签一般只能包含<jsp:param/>标签,如果还包含其他标签就会报上面的错误。

以上纯属猜测,没有见到jsp页面源码,无法仔细分析。

问题已经解决。

返回顶部
顶部