This is just a guess, but is this "line 10" in your C0002_HomeAction class?
if((ses.get("context").toString()!="")&&(ses.get("role").toString()=="admin")){ Based on the exception, I'd say that the Session being null is what's causing the exception. Try changing that line to if((ses != null) && (ses.get("context").toString()!="")&&(ses.get("role").toString()=="admin")){ Another approach would be to implement an interceptor to check whether the user is logged in -- if not, redirect them to the login page. -Brian On Sun, Nov 29, 2009 at 7:57 PM, Nguyen Xuan Son <yama...@gmail.com> wrote: > dear all > I have the C0002_Home.jsp and sessionChk.jsp files. The C0002_Home.jsp's > source code is > <s:action name="SessionCheck"></s:action> > > the meaning of this source code is to check users session whenever they > enter the webpage > the struts.xml is structured as: > <action name="SessionCheck" class="com.baibai.action.SessionCheckAction"> > <result name="input">sessionChk.jsp</result> > </action> > <action name="C0002_Home" class="com.baibai.action.C0002_HomeAction"> > <result name="input">C0002_Home.jsp</result> > </action> > > the detail of the SessionCheckAction.java file is > public class SessionCheckAction extends ActionSupport{ > public String execute() throws Exception { > Map ses = ActionContext.getContext().getSession(); > > if((ses.get("context").toString()!="")&&(ses.get("role").toString()=="admin")){ > // the user is loginned as an administrator > System.out.println("you have session"); > } else { > System.out.println("you dont have session"); > } > return SUCCESS; > } > } > > however when i tried to enter the C0002_Home.jsp without Login > the error appears > 2009/11/30 10:40:07 > com.opensymphony.xwork2.util.logging.commons.CommonsLogger error > 致命的: Could not execute action: /SessionCheck > java.lang.NullPointerException > at com.baibai.action.SessionCheckAction.execute(SessionCheckAction.java:10) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) > at java.lang.reflect.Method.invoke(Unknown Source) > > this doesnt happen if I login into the system > could you tell me where did I went wrong > > -- > ======================================================================= > Ritsumeikan University, Asia JinZai Project > Master of Information Science > Nguyen Xuan Son > > Add : Japan, Shiga-Ken, Kusatsu-Shi, Kasayama 3choume 1-18 > ShiteiHaimu > Rien, Room 103 > Tel/Fax : 81-(0)90-3976 2246 > Email : nr000...@ed.ritsumei.ac.jp > Mobile : 81-(0)90-3976 2246 URL : http://www.ritsumei.jp > ======================================================================= >