How to check when session is expired while using DOJO

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • plsHelpMe
    New Member
    • Jan 2008
    • 58

    How to check when session is expired while using DOJO

    Hi All,

    I am having a problem. I am using DOJO toolkits to fetch some data on my webpage. Now suppose if i leave my webpage for some time and the session gets expired and then i try to click on the link which invokes the DOJO(AJAX) call, it tries to re-authenticate and establish a session by itself. But, it then forwards me the authentication JSP as result of DOJO call instead of the intended JSP. PLease let me know how to track if the session has been expired in DOJO calls. Or if you have any solution for this problem.
    Note: I using the following
    Java Struts/ Dojo toolkit
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Just check if the authentication JSP is returned or you could use another JSP file which returns true or false depending on whether the session has expired or not.

    Comment

    • plsHelpMe
      New Member
      • Jan 2008
      • 58

      #3
      Originally posted by acoder
      Just check if the authentication JSP is returned or you could use another JSP file which returns true or false depending on whether the session has expired or not.
      hi acoder,
      Actually in my application whenever session gets expired and you try to hit the server, you are autometically authenticated first. Now in my case the application's automatic attempt of authenticating it returns me the code of the jsp which gets displayed just after you login to the application. Its a kind of jsp showing that you are using ssl connection and click on OK to continue.
      In order to proceed further i have to click on the ok button on this jsp. I dont know how to do it. I dont want to show this jsp in any div on my page. Moreover if i refresh the page i get the jsp which is having the coding which i utilise when normally return from ajax call. The code of this jsp gets displayed to me.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        You can display the page in a hidden iframe. Then access the iframe and use the button's click() method.

        What does the OK button do? Does it submit a form?

        Comment

        • plsHelpMe
          New Member
          • Jan 2008
          • 58

          #5
          Originally posted by acoder
          You can display the page in a hidden iframe. Then access the iframe and use the button's click() method.

          What does the OK button do? Does it submit a form?
          Yes the OK buttton submits a form to an Action which creates the entitlements and lots of other things and forward it to the action which is handling my ajax call. That action forward to the jsp which is having some data which i am using in my original jsp

          Comment

          • dmjpro
            Top Contributor
            • Jan 2007
            • 2476

            #6
            Originally posted by plsHelpMe
            Hi All,

            I am having a problem. I am using DOJO toolkits to fetch some data on my webpage. Now suppose if i leave my webpage for some time and the session gets expired and then i try to click on the link which invokes the DOJO(AJAX) call, it tries to re-authenticate and establish a session by itself. But, it then forwards me the authentication JSP as result of DOJO call instead of the intended JSP. PLease let me know how to track if the session has been expired in DOJO calls. Or if you have any solution for this problem.
            Note: I using the following
            Java Struts/ Dojo toolkit
            What I understood from your Question that is, you are trying to check whether session expired or not. And that is you are doing through a AJAX call. If AJAX call can successfully determine then it re-authenticates and establishes a new session. Right?
            First let me know that. Then show me your code how much you did.

            Debasis Jana

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              Originally posted by plsHelpMe
              Yes the OK buttton submits a form to an Action which creates the entitlements and lots of other things and forward it to the action which is handling my ajax call. That action forward to the jsp which is having some data which i am using in my original jsp
              If it's a submit button, just make a request to the action page instead with all the POST parameters sent using the send() method.

              Comment

              • plsHelpMe
                New Member
                • Jan 2008
                • 58

                #8
                Originally posted by acoder
                If it's a submit button, just make a request to the action page instead with all the POST parameters sent using the send() method.

                Hey buddy,

                I am not suppose to touch the JSp behind that OK button

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  Originally posted by plsHelpMe
                  Hey buddy,

                  I am not suppose to touch the JSp behind that OK button
                  Who said you have to change anything? Just look at what is posted and post that using Ajax. If that doesn't work, post your code from the beginning.

                  Comment

                  • riyaztak
                    New Member
                    • Feb 2009
                    • 4

                    #10
                    Session timeout how to check?

                    Hi All
                    I have a problem
                    I m using dojo to send a request.
                    But suppose my session has expired and i try to send request;it goes into infinite loop.
                    So will anyone telll me how to check whether session has expired or not?

                    I m using Dojo toolkit and jsp.
                    Thanx

                    Comment

                    • acoder
                      Recognized Expert MVP
                      • Nov 2006
                      • 16032

                      #11
                      In your JSP code, you'll probably have some code which checks whether the user is logged in. If not, it will display the login page. So using that check, you can determine if the session has timed out or not.

                      If the session has timed out, return false, so in the response from the Ajax call, you can test for that.

                      Comment

                      • riyaztak
                        New Member
                        • Feb 2009
                        • 4

                        #12
                        Hi
                        Thnx for reply.
                        Actually in my application one filter is there which will check whether session is
                        expired or not.
                        If i make simple call it works fine but in case on ajax call it goes into infinite loop.

                        Code:
                        var bindArg = {
                            url:"xyz.action",
                            sync:true,
                            content:params,
                            load:function(type, data, evt) {
                               process(data);
                           }
                        };
                        dojo.io.bind(bindArg);
                        Last edited by Dormilich; Feb 23 '09, 01:40 PM. Reason: added code tags

                        Comment

                        • riyaztak
                          New Member
                          • Feb 2009
                          • 4

                          #13
                          I have even tried to check status as well using evt.status.

                          but in case of session expired control doesn't go there

                          Comment

                          • acoder
                            Recognized Expert MVP
                            • Nov 2006
                            • 16032

                            #14
                            When you say it works fine in the case of a simple call, what does it show/return?

                            You can't check the status property of the XMLHttp object because that's the status of the request.

                            Comment

                            • riyaztak
                              New Member
                              • Feb 2009
                              • 4

                              #15
                              In case of simple call if session has expired the control will goto login page but in case of ajax call it goes into infinite loop.

                              Comment

                              Working...