out.write()
空指针异常这是servlet代码:
public class RequestTest3 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws
ServletException,
IOException {
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,然后输出,运行时出现
空指针异常,这是什么回事啊?求各位高手帮帮忙!
------解决方案--------------------为什么要拿application取request域的值?