File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Thread.sleep not working in a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Thread.sleep not working in a servlet" Watch "Thread.sleep not working in a servlet" New topic
Author

Thread.sleep not working in a servlet

Arka Sharma
Ranch Hand

Joined: Jun 15, 2011
Posts: 103


Hi,

I have one servlet where I have called Thread.sleep(5000) in order to display the page for 5 seconds after that I have called sendredirect to a jsp page.
But the problem is that the redirect is working fine but the servlet is not being paused for 5 second.Please help.

Regards,
Arka
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

Note that you can't do both (display a page which essentially sending a response & redirect) at the same time in a servlet.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Arka Sharma
Ranch Hand

Joined: Jun 15, 2011
Posts: 103


How to do it otherwise ? What I want is that the outputp of servlet will be displayed for a while then it will be automatically redirect to some other page
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

You'll need to do that with JavaScript on the client, or via an HTML meta tag.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

An example here.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread.sleep not working in a servlet
 
Similar Threads
WAR deployment on WAS 5
How to throw open a html from a servlet which is called by another servlet ?
How to navigate from jsp-to servlets-and again to another -jsp
starting rmid
Request parameter is missing