So I am trying to get a servlet to add a Java object to the session of the user, when this servlet is requested. But after the servlet redirects to the next page and I try to retrieve the object, I get a null
object instead.
Here is what I do to add the object to the HttpSession (in the servlet):
request.setAttribute("object", obj);
Then I try to retrieve it by (in the JSP):
Object obj = request.getAttribute("object");
So how would I get obj to not be null?
Update:
I have also tried this with nothing:
HttpSession session = request.getSession();
session.setAttribute("object", obj);
with the following in the JSP:
Object obj = request.getSession().getAttribute("object");
Both ways still return null.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…