public HttpSession getSession(boolean create) ...{ if (crossContext) ...{ // There cannot be a session if no context has been assigned yet if (context ==null) return (null); // Return the current session if it exists and is valid if (session !=null) return (session.getSession()); // 我的注释:这里将获取PORTAL系统的SESSION对象。 HttpSession other =super.getSession(false); if (create && (other ==null)) ...{ // First create a session in the first context: the problem is // that the top level request is the only one which can // create the cookie safely other =super.getSession(true); } if (other !=null) ...{ Session localSession =null; try...{ // 我的注释:this context did not have the session with session id. It can just be found in the Portal // context. So here it will return a null value. localSession = context.getManager().findSession(other.getId()); localSession.access(); //我的注释:Here, localSession is null. So it throws a NullPointException. }catch (IOException e) ...{ // Ignore } if (localSession ==null) ...{ localSession = context.getManager().createEmptySession(); localSession.setNew(true); localSession.setValid(true); localSession.setCreationTime(System.currentTimeMillis()); localSession.setMaxInactiveInterval (context.getManager().getMaxInactiveInterval()); localSession.setId(other.getId()); } session = localSession; return session.getSession(); } returnnull; }else...{ returnsuper.getSession(create); } }