I am printing some values on a JSP from session using < bean:write />
successfully. But after submitting the page if I come back (after session expiry) and refresh page it print complete strack trace on the page saying;
< session attribute name> not found in session scope.
To avoid this I have done 2 things. But nothing worked for me.
- I had wrapped
< bean:write />
inside< logic:empty />
- In the starting of the page I just checked whether value of
< session attribute name>
is null. If so, I am redirecting it to error page.
Same problem I am facing if I add attributes in request instead of session.
< request attribute name> not found in request scope.
Code from JSP to check session
HttpSession sess = request.getSession(false);
if (sess == null) {response.sendRedirect("errorpg.jsp");}
else{
String sessionId_Logon = (String) sess.getAttribute("attrName");
if(sessionId_Logon == null)
{
response.sendRedirect("errorpg.jsp");
}
}
I know that "else" block is sense less. I had tried it alone as well.