Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

timer interval before jsp Forward ?

 
sarim raza
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there any way in jsp to wait say 3 secs before the jsp forward tag functions ?
thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you could always put the thread to sleep for 3 seconds. But that doesn't really sound like a happy thing to do.
What are you trying to accomplish by the wait?
bear
 
sarim raza
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can i make the thread to sleep ?
which thread ?
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thread.currentThread().sleep( 3000 ) should make the currently executing thread sleep for three seconds. However, I wouldn't recommend trying to manipulate threads that the application server is managing. It is highly frowned upon!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What James said. Not a great idea.
Why not clue us in on what you are trying to accomplish and maybe someone can suggest a happier way to get it done?
hth,
bear
 
Ali Hassaan
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just use following function of javascript for making some delay and sending to next page.
window.setTimeout("url", 2000);
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is not possible to use Javascript at the server side.
Originally posted by Ali Hassaan:
just use following function of javascript for making some delay and sending to next page.
window.setTimeout("url", 2000);
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think Ali's point is that if the original poster is trying to effect a delay on the client, that doing so on the client makes a lot more sense than stalling the server.
Without more information on what the original poster is trying to accomplish, it's difficult to come up with a reaasonable mechanism.
bear
 
Med Shabe
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, since Sarim doesn't wanna share his scenario I will.
I'm using an intemediary page to tell the user that their password was changed successfully, before forwarding them to the action page. How do I pause i this intermediary page for a few seconds?
I tried something like this:

before doing this:

The redirect works but no pausing happens.
Thanks.
[ August 22, 2002: Message edited by: Med Shabe ]
[ August 22, 2002: Message edited by: Med Shabe ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Med, that is because your redirect is happening long before the javascript gets a chance to execute.
Remember that the java scriplets in your page execute on the server before the page gets sent to the client. Your redirect is causing the client to request the SelectData.jsp page before the page containing your javascript is even sent.
One way to effect what you are after is to have your intermediary page display a "working..." message while the setTimeout calls a javascript function that then loads the SelectData page. That way, the client is in control of the delay and when the next page gets loaded.
hth,
bear
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Med Shabe:
Well, since Sarim doesn't wanna share his scenario I will.
I'm using an intemediary page to tell the user that their password was changed successfully, before forwarding them to the action page. How do I pause i this intermediary page for a few seconds?
I tried something like this:

before doing this:

The redirect works but no pausing happens.
Thanks.
[ August 22, 2002: Message edited by: Med Shabe ]
[ August 22, 2002: Message edited by: Med Shabe ]

Are you looking to do something similar to what it does when you post to one of these topics? It brings up a page that says something like "thank you for posting, we are taking you back to blah blah blah." And, within a few seconds, it redirects you back to the topic you posted to. Is that what you want? Well, here's the code you'll need. You need to include something like this in your <head> section of your html page...
<meta http-equiv="refresh" content="5;http://www.yahoo.com">
This will forward to www.yahoo.com after 5 seconds. However, it's usually nice to place a link to the URL in case the user wants to jump right to it or doesn't feel like waiting 5 seconds (impatient users).
Hope this helps!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic