my dog learned polymorphism*
The moose likes JSP and the fly likes timer interval before jsp Forward ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "timer interval before jsp Forward ?" Watch "timer interval before jsp Forward ?" New topic
Author

timer interval before jsp Forward ?

sarim raza
Ranch Hand

Joined: Nov 02, 2000
Posts: 232
is there any way in jsp to wait say 3 secs before the jsp forward tag functions ?
thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sarim raza
Ranch Hand

Joined: Nov 02, 2000
Posts: 232
how can i make the thread to sleep ?
which thread ?
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
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!


James Carman, President<br />Carman Consulting, Inc.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

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

Joined: May 16, 2001
Posts: 103
just use following function of javascript for making some delay and sending to next page.
window.setTimeout("url", 2000);
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

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);


Groovy
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

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

Joined: May 08, 2001
Posts: 84
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

Joined: Jan 10, 2002
Posts: 61437
    
  67

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

Joined: Feb 20, 2001
Posts: 580
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!
 
 
subject: timer interval before jsp Forward ?