7 Replies Latest reply: Apr 11, 2012 1:30 PM by Nooruddin Shaik RSS

    Unable to fetch Shopping Cart Object on deleting Session Cookies

    EnochSingh
      Hello Everyone,

      I'm facing a strange scenario while submitting an Order for an anonymous user. Following are the details:

      1. I'm invoking a third party service for verification once an order is checked out and in turn, the third party redirects with success response to our page.

      2. We then invoke a Droplet (from the redirected page) that gets the current order to process and submits it using PipelineManager ( getPipelineManager().runProcess() )and OrderManager ( getOrderManager().processOrder() )

      3. After invoking getOrderManager().processOrder() we are setting current order to shoppingCart.last and then redirecting it to Thankyou page where Order Number and its details are displayed.

      The Problem is:

      1. When delete Session Cookie before checking out an order using the above flow, though the order is getting SUBMITTED but I'm not able to get the shoppingCart component at the thankyou page.

      2. The flow works fine if I do not delete the session cookie with the Order details available at the Thank you page.

      Any Clue to the problem will be a great help.

      Thanks In Advance,
      Enoch

      P.S.: I'm not using formhandler for order creation and processing since, Third Party Service are invoked on Checkout of Order.

      Edited by: 926366 on Apr 9, 2012 8:09 AM
        • 1. Re: Unable to fetch Shopping Cart Object on deleting Session Cookies
          Gautam Singh
          The ShoppingCart component is a session scoped component so deleting the session cookie will make the current ShoppingCart component stale(hence inaccessible).
          Why are you deleting the session cookie anyways?
          • 2. Re: Unable to fetch Shopping Cart Object on deleting Session Cookies
            EnochSingh
            Hi Gautam,

            Thanks for you reply.

            Yes, you are correct that ShoppingCart is session scoped component. But I'm confused that why is my order successfully submitted even after deleting the session cookie but I'm not able to access the ShoppingCart component in thankyou JSP alone.

            I tried to debug the flow and found that the new Session object is created and the flow resumes normally till Order Submission but I fail to get the ShoppingCart Component in thankyou Page.

            I only tried to delete the session cookie before actually checking out the order.

            Thanks once again for your reply.

            Regards,
            Enoch
            • 3. Re: Unable to fetch Shopping Cart Object on deleting Session Cookies
              Gautam Singh
              Since you are not using ATG formhandler to checkout it's not breaking your checkout flow
              getOrderManager().processOrder() takes Order object as parameter which has no scope (is backed by repository item and hence a persisted object)

              Though I don't understand why you are not getting ShoppingCart component on thank you page. As you said if you delete the session cookie a new session will be created so next time you are going to access a session scoped component ATG is going to create a new instance.

              What do you mean by "I fail to get the ShoppingCart Component "?
              if you are trying to get current order by calling ShoppingCart.getCurrent() its not going to work as a new instance will be initialized with a null object.
              Submit stack trace if you are getting any exception.

              Also would you mind telling me why you have to delete session cookie?
              • 4. Re: Unable to fetch Shopping Cart Object on deleting Session Cookies
                EnochSingh
                I'm trying to get the ShoppingCart object on thankyou page as follows:

                +...+
                +<dsp:importbean bean="/atg/commerce/ShoppingCart"/>+
                +...+
                Cart Object # <dsp:valueof bean="ShoppingCart"/>
                Last Order Object # <dsp:valueof bean="ShoppingCart.last.id"/>

                Now,

                1. When my Home Page loads, I delete my session cookie (just for testing purpose) and go to product listing page. I select an item and progress to checkout page..I call a third party service which redirects to call PipelineManager and OrderManager process methods (as stated earlier using a Droplet Class invoked from redirected JSP). I can find shoppingCart Object (with same id as it was at the start before deleting the cookie) and using shoppingCart.getCurrent(), I can find the Order object in the Droplet class. But when I redirect to Thankyou Page and try to import ShoppingCart bean object in Thankyou JSP page using above code, I'm not able to get the ShoppingCart Bean and hence, I'm unable to display the last order details.

                2. There are no exceptions available in the above flow.

                The scenario is occurring for each and every fresh order submission (after deleting the session cookie). The flow works fine once I restart my application Server (Weblogic 10.3).

                Hopefully, this will clarify the scenario.

                Thanks & Regards,
                Enoch

                Edited by: 926366 on Apr 10, 2012 4:10 AM
                • 5. Re: Unable to fetch Shopping Cart Object on deleting Session Cookies
                  Nooruddin Shaik
                  It looks you are trying to do this.

                  After session invalidation, you might not be creating new session which you need to create.
                  But this may not solve it completely becoz some session components like profile etc are created as part of pipelineable servlet.
                  So better is after invalidating the session redirect the page to thankyou.jsp using sendLocalRedirect().

                  This should solve the issue.

                  Peace
                  Shaik
                  • 6. Re: Unable to fetch Shopping Cart Object on deleting Session Cookies
                    EnochSingh
                    Hi Shaik,

                    Peace, thanks for your response. I'm already using response.sendLocalRedirect() but still not able to fetch the order.

                    Also, I'm invalidating the session before actually adding the order in ShoppingCart (OrderHolder) and checking out.

                    *...*
                    *if (getShoppingCart() != null) {*
                    order = (UKOrder)getOrderManager().loadOrder(order.getId());
                    getShoppingCart().setLast(order);
                    getShoppingCart().setCurrent(null);
                    response.sendLocalRedirect(
                    getpMoveToConfirmationSuccessURL(), request);
                    *...*

                    I'm confused why getShoppingCart() method return ShoppingCart object but when I use importbean to import ShoppingCart bean on thankyou page it does not import it.

                    This happens only if I invalidate the session before actually checking out the order.


                    Regards,
                    Enoch
                    • 7. Re: Unable to fetch Shopping Cart Object on deleting Session Cookies
                      Nooruddin Shaik
                      hmm, this is strange.
                      Using getShoppingCart() in java or using import bean shouldn't return different.

                      Can you paste the code in the jsp? I suspect you might have some typos.

                      Peace
                      Shaik