JAVAEE SERVLET 报错 求解 急!!!!!!!

jing930807 2014-08-30 03:44:33
import java.io.IOException;
import java.util.List;

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.csuinfosoft.entity.Book;
import com.csuinfosoft.service.BookService;

public class BookTypeServlet extends HttpServlet {

/**
*通过输入书本类型 获得书本的信息
*/
private static final long serialVersionUID = 6736897007827179546L;

protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
doPost(req, resp);
}

protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
// 设置编码集
req.setCharacterEncoding("utf-8");
resp.setCharacterEncoding("utf-8");
resp.setContentType("textml;charset=utf-8");
// 从输入框获取book类型
String booktype = req.getParameter("booktype");
HttpSession session = req.getSession();
String path = req.getServletPath();
if ("/bookType".equals(path)) {
if (booktype != null && !"".equals(booktype)) {
BookService bookservice = new BookService();
List<Book> books = bookservice.getBooksByType(booktype);
// System.out.println(books);
path = "/wenxue.jsp";
req.setAttribute("books", books);
session.setAttribute("booktype", booktype);
}
System.out.println(path);
}
req.getRequestDispatcher(path).forward(req, resp);
}
}

Error:at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:544)
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
...全文
134 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
huasuoworld 2014-08-30
  • 打赏
  • 举报
回复
这参数传的。。

String booktype = req.getParameter("booktype");
HttpSession session = req.getSession();

req.setAttribute("books", books);
session.setAttribute("booktype", booktype);
jing930807 2014-08-30
  • 打赏
  • 举报
回复
引用 1 楼 kifile 的回复:
错误类型呢,你这个只有错误的位置
他只给我报了这个 然后还是无限的重复报错 就像死循环一样
jing930807 2014-08-30
  • 打赏
  • 举报
回复
他只给我报了这个 然后还是无限的重复报错 就像死循环一样
Kifile 2014-08-30
  • 打赏
  • 举报
回复
错误类型呢,你这个只有错误的位置

67,516

社区成员

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

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