It will fail to work when:
You are redirecting the response to a new request by response.sendRedirect("page.jsp")
. The newly created request object will of course not contain the attributes anymore and they will not be accessible in the redirected JSP. You need to forward rather than redirect. E.g.
request.setAttribute("name", "value");
request.getRequestDispatcher("page.jsp").forward(request, response);
You are accessing it the wrong way or using the wrong name. Assuming that you have set it using the name "name"
, then you should be able to access it in the forwarded JSP page as follows:
${name}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…