aspose file tools*
The moose likes Servlets and the fly likes Re: Servlet Redirect with time delay Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Re: Servlet Redirect with time delay" Watch "Re: Servlet Redirect with time delay" New topic
Author

Re: Servlet Redirect with time delay

Joe Cheung
Ranch Hand

Joined: Oct 18, 2002
Posts: 104
Dear all,
When a servlet is called (says, servlet A), and I want to redirect to another html file or servlet file, I will use response.sendRedirect("URL"). However, what I want now is I want to display a page (says, Page B)giving some message to users and redirect with time delay, says, 3 seconds, to another page (says, Page C) for other actions. What should I do in servlet A to achieve the purpose. Page A and Page B can be html files or codes generated by servlet.
Regards,
Joe


Joe
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
The following can be used. This example will load google after 10 seconds.
response.setHeader("Refresh", "10; URL=http://www.google.com")


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Sangel Kapoor
Ranch Hand

Joined: Jan 12, 2013
Posts: 70

Bosun Bello wrote:The following can be used. This example will load google after 10 seconds.
response.setHeader("Refresh", "10; URL=http://www.google.com")



What is the meaning of "Refresh" here ? Is there any constant defined for the same in API.

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

HTTP refresh header


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ron McLeod
Ranch Hand

Joined: Feb 12, 2013
Posts: 328
    
    6

What is the reason for the delay?
  • To make the user is aware that they are being redirected (to another site)?
  • To allow the user's browser back button to continue to work (and not be immediately redirected back again)?
  • To give enough time for dynamic context to be available at the redirected location?

  •  
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Re: Servlet Redirect with time delay