| Author |
problem in session tracking inside my request processor....
|
sajjad ahmad
Ranch Hand
Joined: Jan 23, 2003
Posts: 75
|
|
Hi! i am facing trouble while tracking a session inside my struts application,i am using following code snipit ######################################################## public class MyRequestProcessor extends RequestProcessor { protected boolean processPreprocess ( HttpServletRequest request, HttpServletResponse response) { if(request.getServletPath().equals("/personalLoanIndex.do") || request.getServletPath().equals("/PersonalloanIndex.jsp") ){ UserProfile userProfile = new UserProfile(); userProfile.setUserName(request.getParameter("userName")); userProfile.setUserPassword(request.getParameter("userPassword")); if(userProfile.doesUserExists()){ HttpSession session = request.getSession(); System.out.println("session id is --------> "+session.getId()); session.setAttribute("userProfile",userProfile); } return true; } //If user is trying to access login page // then don't check if( request.getServletPath().equals("/loginAction.do") || request.getServletPath().equals("/login.jsp") ) return true; //Check if userName attribute is there is session. //If so, it means user has allready logged in HttpSession session = request.getSession(false); System.out.println("###############################################################"); System.out.println("---------> session id "+session.getId()); System.out.println("###############################################################"); if( session != null && session.getAttribute("userProfile") != null) return true; else{ try{ //If no redirect user to login Page request.getRequestDispatcher ("/notLogedIn.jsp").forward(request,response); }catch(Exception ex){ } } return false; } } ######################################################## here i can not get the same session (session id is shown different) both in the first and second block . in first block i used HttpSession session = request.getSession(); coz i wanted to have current/new session each time this block is executed .in second block i used HttpSession session = request.getSession(false); coz i wanted to have same old session which i previously made in first block .i think there isn't anything wrong with it then where i is problem raised???i am stuck with this error . NOTE : a strange behavior is that if a try to login my user from login page for the first time i get this problem,but if a try to login the user again from the same window/page i don't get this error and both the sessions from block1 and 2 are same can you please help me in finding out what i am doing wrong here. thanks in advance.
|
 |
 |
|
|
subject: problem in session tracking inside my request processor....
|
|
|