aspose file tools*
The moose likes Servlets and the fly likes Timed Redirect Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Timed Redirect" Watch "Timed Redirect" New topic
Author

Timed Redirect

Pearlo Muthukumaran
Ranch Hand

Joined: Sep 17, 2002
Posts: 79
How to make a redirection from the current page (response.write of servlet) to a different servlet after a fixed time has elapsed? I am not supposed to use meta tag. May be i can use a timer for implementing this.
But no samples are avilable with a timer used within servlet code.
Hope I am clear to the willing responder.
Rgds
Muthu
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61221
    
  66

OK if you can't use the meta tag (I'm assuming this is a homework assignment with such a parameter), the only other real choice is a JavaScript timeout. What you are trying to accomplish must be performed with client-side mechanisms since once the page is sent to the browser, servlets and JSP are out of the picture.
Check out the setTimeout() method on the window object.
hth,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
What about using the setHeader method of the response object. For example, the following will load google's home page after 10 seconds.
response.setHeader("Refresh", "10; URL=http://www.google.com")
Just make the URL the location of your servlet and change the time to whatever you want.
[ April 09, 2003: Message edited by: Bosun Bello ]

Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61221
    
  66

response.setHeader("Refresh", "10; URL=http://www.google.com")

I figured that was "off limits" since that's essentailly what the meta tag does... but I guess it'd all be up to how the assignment is worded.
Good call, Bosun!
bear
Pearlo Muthukumaran
Ranch Hand

Joined: Sep 17, 2002
Posts: 79
But will this not lead to a network roundtrip?
In my case, luckily the "redirected" servlet is also in the same server as that of "redirecting" servlet. Is there any way I could use a RequestDispatcher with the functionality (timed redirection)?
Rgds
Muthu
 
 
subject: Timed Redirect