Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

problem in session tracking inside my request processor....

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
You are HERE! The other map is obviously wrong. Better confirm with this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic