jsp和servlet简单应用,org.apache.catalina.core.ApplicationDispatcher invoke错误

紫竹 2010-11-22 09:14:42
//这个类是Servlet验证用户登录成功类,并且为wel界面要显示的内容准备数据
package com.controller;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.model.UserCl;

public class ControllerServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//得到login.jsp转发过来的信息
String u=request.getParameter("user");
String p=request.getParameter("passwd");
System.out.println(u+"\t"+p);
UserCl uc=new UserCl();
if(uc.checkUser(u, p)){
//将要wel界面要显示的数据传给wel界面
String table = "studenttest";
int allCount=(int)uc.allCount(table);//得到总记录数
System.out.println("总记录数\t"+allCount);
//得到要显示的用户列表
ArrayList a1 = uc.userList(table, 1, 8);
System.out.println("数组\t"+a1);
//将数据发给wel界面
request.setAttribute("al",a1);
request.setAttribute("allCount",allCount+"");
//要显示的页数数字
int allPage=8;
//转发
request.setAttribute("allPage", allPage+"");
System.out.println("allPage:\t"+allPage+"");
//显示的上一页
int pageNow=1;
request.setAttribute("pageNow", pageNow+"");
System.out.println("pageNow:\t"+pageNow+"");
//登录成功
//request.getRequestDispatcher("wel.jsp").forward(request, response);
request.getRequestDispatcher("wel.jsp").forward(request, response);

}
else{
//登录失败
//request.getRequestDispatcher("login.jsp").forward(request, response);
request.getRequestDispatcher("login.jsp").forward(request, response);

}

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

}
这个错误一直在报,实在看不出那个地方错了
2010-11-22 20:50:46 org.apache.catalina.core.ApplicationDispatcher invoke
严重: Servlet.service() for servlet jsp threw exception
严重: Servlet.service() for servlet controllerServlet threw exception
java.lang.NullPointerException
。。。。。。
。。。。。。。
at com.controller.ControllerServlet.doGet(ControllerServlet.java:50)
at com.controller.ControllerServlet.doPost(ControllerServlet.java:64)
。。。。。。
。。。。。。。
50和60行分别是:红颜色的两行
还有,每个地方我都打印了:zizhu 123
总记录数 39
数组 [com.model.UserBean@18e8541, com.model.UserBean@1ce85c4, com.model.UserBean@1b03c1a, com.model.UserBean@139e351, com.model.UserBean@17aece8, com.model.UserBean@1578aab, com.model.UserBean@51127a]
allPage: 8
pageNow: 1

知道的请帮帮忙

...全文
2432 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
紫竹 2010-11-22
  • 打赏
  • 举报
回复
小L和1的区别,这就是程序错误,搞了我两个小时,虽然没人回,还是自己解决了
结贴了
紫竹 2010-11-22
  • 打赏
  • 举报
回复
能传数组对象,但wel.jsp那边接到的是空值,而这边传过去的不是空值,这是为什么??
紫竹 2010-11-22
  • 打赏
  • 举报
回复
好像有转机,报的错传到了wel.jsp界面
我想问的是request.setAttribute("a1",a1);能不能传ArrayList数组对象,在wel.jsp的界面中,request.getAttribute("a1")的时候,得到的是空值。

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧