By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,551 Members | 2,727 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,551 IT Pros & Developers. It's quick & easy.

How to check when session is expired while using DOJO

P: 58
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
Jan 5 '08 #1
Share this Question
Share on Google+
15 Replies


acoder
Expert Mod 15k+
P: 16,027
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.
Jan 5 '08 #2

P: 58
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.
Jan 9 '08 #3

acoder
Expert Mod 15k+
P: 16,027
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?
Jan 9 '08 #4

P: 58
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
Jan 10 '08 #5

dmjpro
100+
P: 2,476
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
Jan 10 '08 #6

acoder
Expert Mod 15k+
P: 16,027
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.
Jan 10 '08 #7

P: 58
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
Jan 10 '08 #8

acoder
Expert Mod 15k+
P: 16,027
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.
Jan 10 '08 #9

P: 4
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
Feb 23 '09 #10

acoder
Expert Mod 15k+
P: 16,027
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.
Feb 23 '09 #11

P: 4
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.

Expand|Select|Wrap|Line Numbers
  1. var bindArg = {
  2.     url:"xyz.action",
  3.     sync:true,
  4.     content:params,
  5.     load:function(type, data, evt) {
  6.        process(data);
  7.    }
  8. };
  9. dojo.io.bind(bindArg);
Feb 23 '09 #12

P: 4
I have even tried to check status as well using evt.status.

but in case of session expired control doesn't go there
Feb 23 '09 #13

acoder
Expert Mod 15k+
P: 16,027
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.
Feb 24 '09 #14

P: 4
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.
Feb 24 '09 #15

acoder
Expert Mod 15k+
P: 16,027
You have two choices: either make a request to another page which simply returns true or false and check for that, or parse the response and look for login code. If it's there, then that means that the session has expired.
Feb 24 '09 #16

Post your reply

Sign in to post your reply or Sign up for a free account.