Hey Dave,

I have one problem....  Action Class

i will tell u the clean scenario.. It is related with the session
validation and invalidation in the same page..

1)  i am logging into the site and retrieved my trip details...  
2)  and i started Initial Search with the same user name and
password...coz it maintains my session..
3)  i went upto 3 steps... (ex: Review Trip page).  there it should
ask only the continue button.. i am getting it. and i logged out from
that session
4)  and in the same screen i started my initial search again..
5)  when i get into the review trip page it should ask for two
options.. one is login option and another on is continue option..
hence i logged out from the first session..

6)  But i am getting only the continue option...  when i looked into
application.log file,  it is given me the same session id and same
JSessionId...

Please tell me how can i come over this problem

here is the code change i have made to validate and invalidate the session:---

  private void validateSession( HttpServletRequest request,
                                HttpServletResponse response,
                                SessionManager sessionManager )
      throws ActionSessionException
  {
    HttpSession httpSession = request.getSession();
    Session sessionToken = getSession( request );

    if ( isDebugEnabled() )
    {
      logDebug( "AbstractTpAction::validateSession( )-->",
                "Found session token. Will try to validate it" );
    }

    //TODO: will be replaced by 'DONT_CREATE_TP_SESSION'.
    if ( sessionToken.getTpSession().getLastKnownState() ==
TpSessionState.TPNOTAVAILABLE && !isTPUsed )
    {
        createSession( request, response, sessionManager );
        return;
    }

    if ( !isTPUsed )
    {
      return;
    }


    // Copy the current session ID from cookie for any of the 888 applications
    // if this isn't the first time they've validated the session.
    // Their session IDs change everytime they go to the 888 home page and
    // if we try to validate the new vs. old, it fails.
/*   
    TpPdbResponse tpPdbResponse = null;
    TpDataManager tpDataManager;
    tpDataManager = (TpDataManager) lookupComponent(  TpDataManager.ROLE );
    
    
    
    try
    {
        tpDataManager.retrievePDB( getSession ( request ), "cookie_uid");
        tpDataManager.retrievePDB( getSession ( request ), "sh_SID");
                tpDataManager.retrievePDB( getSession ( request ), "sh_login_list");
    }
    catch (ManagedComponentException ex)
    {
        logError("AbstractTpAction: error in retirevePDB", ex);
    }
    finally
    {
        getComponentManager().release (tpDataManager);
    }

*/      
    
  
 
        HttpDataManager httpDataManager = null;
        TpDataManager tpDataManager = null;
        httpDataManager = ( HttpDataManager ) lookupComponent(
HttpDataManager.ROLE );
        httpDataManager.getPersistentValue(request, "SID");

        
        logDebug( "Cookie Value -
>",httpDataManager.getPersistentValue(request, "SID"));
                
        if ( httpDataManager.getPersistentValue(request, "SID") == null)
        {
                tpDataManager = ( TpDataManager ) lookupComponent( TpDataManager.ROLE 
);
                try
                {
                        TpResponse tpResponse = tpDataManager.invalidateSession(
getSession(request) );
                        httpSession.invalidate();
                        createSession( request, response, sessionManager ); 
                
                        sessionToken = getSession( request );
                
                        request.setAttribute( "FIRST_REQUEST", "FIRST_REQUEST" );
                        return; 
                }catch ( ManagedComponentException ex )
                {
                          logError( "AbstractTpAction: error in invalidation tpSession 
", ex );
                }
                finally
                {
                          getComponentManager().release( httpDataManager );
                }               
        }
                    
    if ( ValidateUtil.validateNotNull( sessionToken.getSessionId() ) &&
        sessionToken.getServiceTag().endsWith( "PHONE" ) )
    {
      try
      {
        String tpSessionId = httpDataManager.getPersistentValue( request,
                                                                 "SID" );
        if ( ValidateUtil.validateNotNull( tpSessionId ) )
        {
          sessionToken.getTpSession().setSessionId( tpSessionId );
        }
      }
      finally
      {
        getComponentManager().release( httpDataManager );
      }
    }
    

    
    
 /*
    if ( ValidateUtil.validateNotNull( sessionToken.getSessionId() ) &&
        sessionToken.getServiceTag().endsWith( "PHONE" ) )
    {
      HttpDataManager httpDataManager = null;
      try
      {
        httpDataManager = ( HttpDataManager ) lookupComponent(
HttpDataManager.ROLE );
        String tpSessionId = httpDataManager.getPersistentValue( request,
                                                                 "SID" );
        if ( ValidateUtil.validateNotNull( tpSessionId ) )
        {
          sessionToken.getTpSession().setSessionId( tpSessionId );
        }
      }
      finally
      {
        getComponentManager().release( httpDataManager );
      }
    }
*/

    SessionValidateRequest sessionValidateRequest =
        new SessionValidateRequest( sessionToken, Boolean.FALSE );
    String forceValidation = request.getParameter( "forceValidation" );

    if ( isDebugEnabled() )
    {
      logDebug( "AbstractTpAction::validateSession( )--> FIRST_REQUEST=",
                request.getAttribute( "FIRST_REQUEST" ) );
    }

    if ( ( ValidateUtil.validateStringNotEmpty( forceValidation ) &&
        "Y".equals( forceValidation ) ) ||
        !ValidateUtil.validateNotNull( request.getAttribute(
"FIRST_REQUEST" ) ) )
    {
      sessionValidateRequest.setForceValidation( Boolean.TRUE );
    }

    if ( !ValidateUtil.validateNotNull( request.getAttribute(
"FIRST_REQUEST" ) ) )
    {
      request.setAttribute( "FIRST_REQUEST", "FIRST_REQUEST" );
    }

    SessionResponse sessionResponse =
        sessionManager.validateSession( sessionValidateRequest );

    if ( ResponseUtil.isSuccess( sessionResponse ) )
    {

      sessionToken = sessionResponse.getSession();
      AssertUtil.assertNotNull( sessionToken );

      if ( isDebugEnabled() )
      {
        logDebug( "", sessionToken.toString() );
      }

      httpSession.setAttribute( WebApplicationConstants.SESSION_TOKEN,
                                sessionToken );

      //Store Session for use with GlobalSession
      GlobalSessionManager.setSid( sessionToken.getTpSession(
).getSessionId( ) );
      GlobalSessionManager.setSession( sessionToken );

      checkSessionUserInformation( sessionResponse, httpSession );
    }
    else if ( sessionResponse.getStatus( ) != null &&
              TpResponseCode.TP_SID_EXPIRED.equals(
sessionResponse.getStatus( ).getCode( ) ) )
    {
      logDebug(
          "AbstractTpAction::validateSession( )--> The last TP session
was expired ....Creating a new Java session" );
      createSession( request, response, sessionManager );
    }
    else
    {
      logWarn( "AbstractTpAction::validateSession--> session response",
               sessionResponse.getStatus() );
      logWarn( "AbstractTpAction::validateSession--> " +
               "removing SessionToken from httpSession!" );

      httpSession.removeAttribute( WebApplicationConstants.SESSION_TOKEN );

      //remove sid for use with GlobalSession
      GlobalSessionManager.removeSession( sessionToken.getTpSession(
).getSessionId( ) );

      throw new ActionSessionException( "Fatal Error. Session object
has expired. Response = " +
                                        ObjectUtil.toString(
sessionResponse ) );
    }
  }


Cheers!!!!!

Kannan

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to