我在 com.company.abc 中编写了一个 servlet 代码,即
public class Controller extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
XYZ xyz = new XYZ();
int value = xyz.fucn();
request.setAttribute("value", value);
request.getRequestDispatcher("page.jsp").forward(request, response);
}
}
web文件夹下的page.jsp文件
<html>
<head>
<title>My JSP 'indexnewpage.jsp' starting page</title>
</head>
</body>
<%
Object value = request.getAttribute("value");
%>
<p><%=value%></p>
<body>
</html>
现在我想在 JSP 页面中查看 Object 值的值,但是我看不到请帮助我,如果您发现其中有任何错误,请更正代码,或者帮助我将值从 servlet 获取到 jsp 页面示例代码。