Sunday, February 3, 2008

Meta refresh redirect - Don't use it

Meta refresh breaks the Back button - http://www.w3.org/QA/Tips/reback

Sample code for Meta refresh redirect:

<html>

<head>
<title> Redirecting to correct page </title>
<META http-equiv="refresh" content="5;URL=http://jhpatel.blogspot.com/"> </head>

<body>
<center>
You will be redirected automatically in 5 seconds. Please bookmark the page at
<a href="http://jhpatel.blogspot.com/" > http://jhpatel.blogspot.com/</a>
</center>
</body>

</html>


Better way :

HTTP 301 Redirect - Permanent redirect (In JSP)

response.setStatus(301);

response.setHeader("Location", "http://www.jhpatel.blogspot.com/");

response.setHeader("Connection", "close");

1 comment:

Inventory Management Software said...

Thanks for sharing your post and it was superb .I would like to hear more from you in future too.