日期:2014-05-17  浏览次数:20894 次

out.write()空指针异常
这是servlet代码:
public class RequestTest3 extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletExceptionIOException {
            String data = "qqq";
            request.setAttribute("data", data);
            request.getRequestDispatcher("/requestJsp.jsp").forward(request, response);
}
}

这是JSP代码:
<body>
    <%
    String message = (String)application.getAttribute("data");
    out.write(message);
     %>
  </body>
我把servlet的数据传给JSP,然后输出,运行时出现空指针异常,这是什么回事啊?求各位高手帮帮忙!
Servlet JSP 异常

------解决方案--------------------
为什么要拿application取request域的值?