Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Redirecting...

 
Tom Diamond
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Is there a smart way to redirect to another page after a specific amount of time? (2 seconds for example).
Tom.
 
Jared Krull
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally, I prefer to use good old JavaScript....
<HTML>
<HEAD>
</HEAD>
<SCRIPT>
<!-- START HIDE
function jmp(){
document.location.href="http://www.Yahoo.com/"
}
// STOP HIDE -->
</SCRIPT>
<BODY onload="setTimeout('jmp()',2000)">
</BODY>
</HTML>
That's set for 2 seconds
------------------
C programmer gone astray
 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can. You need to set it in the response.setHeader()
Here is an example that loads the Google page after 20 seconds.
response.setHeader("Refresh", "20; URL=http://www.google.com")

Bosun
 
Tom Diamond
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx for your answers.
The JavaScript stuff works fine but not for my case : the redirection link is not static but it is "calculated" inside a snippet (the page that contains the redirection does some kind of proccesseing and may be called from various pages. I want to redirect the user at the page he submitted the information). As soon as I know Javascript does not "see" Java variables declared in a JSP (the calculated link is a string). I tried the following :
response.setHeader("Refresh", "2; URL=" + myLink)
but the server said :
org.apache.jasper.JasperException: Unable to compile class for JSP response.setHeader("Refresh", "2; URL=" + pageLink)
Any further ideas?
Tom.

[This message has been edited by Tom Diamond (edited October 16, 2001).]
 
Tom Diamond
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone with an idea???
 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tom, if this ("Refresh", "2; URL=" + pageLink) is the exact way you had it, you are missing a closing quote. It should be
("Refresh", "2; URL=" + pageLink")

Bosun
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually...
("Refresh", "2; URL=\"" + pageLink + "\"")
isn't it?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic