How to update session attribute

前端 未结 2 653
眼角桃花
眼角桃花 2021-02-10 02:40

I have some session attributes being saved. I have a jsp page on which a call to a servlet is made through. This servlet updates one of the session variable but I am not able to

2条回答
  •  南笙
    南笙 (楼主)
    2021-02-10 03:13

    To access the abc variable in the JSP try:

    ${sessionScope.abc}
    

    Also note that removing before setting is usually redundant. So:

    request.getSession().removeAttribute("abc");
    request.getSession().setAttribute("abc", abc);
    

    Can simply become:

    request.getSession().setAttribute("abc", abc);
    

提交回复
热议问题