When my website's session is expiring it shows an error message like below when trying to access some pages.But for other pages though the session is expired ,when trying to access them ,it prompts to the login page asking user to log again as the session is expired.So i want to eliminate error message for firstly said pages, and make it prompts to login page when they are trying to be accessed as happened in secondly said pages.i'm a beginner So please help me to do this. This is the error being displaced.I'm using jboss server.Please tell me how to do this.
javax.servlet.ServletException: user name can not be null org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) javax.servlet.http.HttpServlet.service(HttpServlet.java:697) javax.servlet.http.HttpServlet.service(HttpServlet.java:810) org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
java.lang.IllegalArgumentException: user name can not be null com.atlinkcom.bestcarelab.dal.UserPrivilegeDAL.getUserIdByUsername(UserPrivilegeDAL.java:109) com.atlinkcom.bestcarelab.manager.UserManager.addUserActivity(UserManager.java:657) com.atlinkcom.bestcarelab.action.order.GetSchedulesForWelcomeAction.execute(GetSchedulesForWelcomeAction.java:50) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) javax.servlet.http.HttpServlet.service(HttpServlet.java:697) javax.servlet.http.HttpServlet.service(HttpServlet.java:810) org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter [ November 20, 2008: Message edited by: prashan dassanayake ]
It looks like some of your servlets/jsps are handling session expiration cases and some are not. Look at the code for the pages which show the login page on session expiration and see how it is handled. Do the same for other pages.
Also, if user authentication code is duplicated in many places, it is good idea to bring it in one place, preferably in your Controller or in a Filter.
Joined: Nov 07, 2008
i'm a very first beginner.So can you tell me please in which kind of files these expiration handling codes are being written and where can be these files found.If you can please give me an example code
To get login page..you need to write a servlet or any controller and check for invalidate seesion ..if it is not live ..redirect to login page from controller it self, and also define this servlet with <load-on-startup> in web.xml..
[BPSouther: Added code tags] [ November 21, 2008: Message edited by: Ben Souther ]
Joined: Oct 26, 2006
Now if we look at the code posted by you the the problem lies here
Which means the parameter passed to this method itself is null. I would like you to do some analysis now,
Look at these methods addUserActivity() of com.atlinkcom.bestcarelab.manager.UserManager and execute of this action com.atlinkcom.bestcarelab.action.order.GetSchedulesForWelcomeAction
check where the user variable is instanciated and assigned a value, should be somewhere in these two methods above i reckon. Put some log messages in these two methods at meaningful places and try executing it again. Now access the pages where you are getting this exception and then those where it is directed to login page on session expiry. Check for these things Is this action and UserManager class coming in picture for the pages where it is directed to login page on session expiry?
If yes, check why this username is not null in that case.
Please post back if you have any doubts or problems in doing this. [ November 20, 2008: Message edited by: Amol Nayak ]