我有一种情况,我需要更新名称保持不变的 setAttribute 的值。考虑以下情况作为示例 -
假设我有三个 JSP:abc.jsp、xyz.jsp、pqr.jsp。现在首先运行 abc.jsp,然后将控制转发到 xyz.jsp,然后转发到 pqr.jsp。现在在执行 pqr.jsp 后,控件再次返回 xyz.jsp,并在 setAttribute 处更新了值。
abc.jsp:
ArrayList<Books> getSupplyStatus=new ArrayList<Books>();
JavaBean javaBean=new JavaBean();
session=request.getSession(false);
getSupplyStatus=javaBean.getSupplyStatus(memberID); //It returns a ArrayList
if(!getSupplyStatus.isEmpty())
{
session.setAttribute("UpdatedBooklist", getSupplyStatus);
request.getRequestDispatcher("xyz.jsp").forward(request, response);
}
xyz.jsp:
session=request.getSession(false);
ArrayList<Books> getSupplyStatus=(ArrayList<Books>) session.getAttribute("UpdatedBooklist");
// some operations & forward to pqr.jsp
pqr.jsp:
// in this jsp new ArrayList<Books> will be prodeuced
// & I need to bound the value of "UpdatedBooklist" with
// which is set in abc.jsp,
// and previous value must be override & then forward to xyz.jsp again
// In xyz.jsp we recieve the updated value.