• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Redirect

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On some websites including java ranch, there is a function whereby the web page shows that the user will be redirected to another page in a few seconds. How is this done programmatically?

I tried on a redirect.jsp
<%
Thread.sleep(30);
RequestDispatcher dis = request.getRequestDispatcher(/next.jsp);
dis.forward(request, response);
%>
but i see next.jsp straight away without seeing the contents of redirect.jsp.

Can someone gimme a clue? Thanks in advance.
 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you will need to use javascript for using the redirect and the reason for this is you need the page to be loaded and then you want it to redirect.
you could write a function in javascript using the settimeout() for doing this.
look into the setTimeout() documentation and i am sure you will come up with the solution.

One thing which is wrong in your method is the timeout is at the host and the page will not load unless the timeout expires. that is when the server will respond. you may not be noticing the difference as the time you have specified is too small 30 millis.
javascript is the way to go.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You either do like below.

 
reply
    Bookmark Topic Watch Topic
  • New Topic