Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is there any way to delay including a page in jsp

 
Neil Grace
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic