当你发送信息到JSP,你需要dispacth当前请求JSP,我尝试了上面的代码,我没有任何问题,这是我的代码:
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String saludo="hi";
req.setAttribute("exito",saludo);
req.getRequestDispatcher("MyPage.jsp").forward(req, resp);
}
而且这是MyPage.jsp代码
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Title</title>
</head>
<body>
${exito}
</body>
</html>
[在JSP不工作表达式语言(http://stackoverflow.com/questions/2168832/expression-language-in-jsp-not-working) –
的重复尝试使用JSTL include <%@ taglib prefix =“c”uri =“http://java.sun.com/jsp/jstl/core”%>然后尝试 –
user1769790