I use the Struts2 framework and I have a custom interceptor. The interceptor stack is the defaultStack
+ my custom interceptor at the bottom (right before the action). In the intercept method I use the following code:
final ActionContext context = invocation.getInvocationContext ();
HttpServletRequest request = (HttpServletRequest) context.get(StrutsStatics.HTTP_REQUEST);
HttpSession session = request.getSession(true);
session.doSomething();
I was wondering why the used methods don't throw any exceptions, and why it isn't necessary to check if(session != null)
. Is it not possible for those methods to fail to get an instantiated session? Why? Does the servlet-config interceptor have anything to do with this? If session can be null
, in what kind of situation does this happen?