URL redirect errors
I am trying to use a simple redirect command that will direct users to a new web page based upon a pre-defined condition. When the script runs the condition is recognized and IE attempts the redirect but i get an error saying Error: Object Expected. here is my code. I have also tried using the response.sendRedirect and res.sendRedirect commands and I get a message saying 'response' is undefined. please help.
if (browser != "Microsoft Internet Explorer")
{
redirect("http://myserver.com/xyz.html");
}
thanks,
Matt
If you are using a servlet try
public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
res.sendRedirect("your page");
}
in a jsp page response.sendRedirect("your page"); should do it.
P.S.: You should use "if(!browser.equals("Microsoft Internet Explorer")) {}" instead of !=
Are you trying to do this using Java or JavaScript?
I would do this using the JavaScript shown in context below
<html>
<head>
<!-- the Script starts here-->
<SCRIPT Language="JavaScript">
var navName = navigator.appName;
if(navName != "Microsoft Internet Explorer")
{
window.location="http://www.myserver.com/abc/html";
}
</SCRIPT>
<!--and ends here-->
</head>
</html>