| Author |
Is there any way to delay including a page in jsp
|
Neil Grace
Greenhorn
Joined: Oct 03, 2011
Posts: 2
|
|
I have two includes in my jsp. What i want to do is make the second include after some delay. How can I do that? Thanks.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56192
|
|
You can't. Not with JSP technology, at least.
What you need to do is to start a JavaScript timer when the page loads, and when the timer expires, grab the page fragment to be included via an Ajax request.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56192
|
|
This is almost trivial with jQuery's help.
Put an empty div in the page where the delayed content is to be placed, like:
Then use the following script:
This will fetch the delayed content 1 second after the page loads and stick it into the empty div.
|
 |
Neil Grace
Greenhorn
Joined: Oct 03, 2011
Posts: 2
|
|
Thanks for the reply. What I am trying to achieve is:
I want to show Page2.jsp based on a session attribute that will be set by the AJAX call from Page1.jsp. So I want to delay the displaying of page2.jsp and subsequent page unless I get response back from AJAX call made.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56192
|
|
|
The instead of doing it in a ready handler with a timeout as I showed, you'd do the .load() in the success handler of the previous Ajax request. Why didn't you put all that in the initial topic?
|
 |
 |
|
|
subject: Is there any way to delay including a page in jsp
|
|
|