Skip to main content

java url redirection

An example of redirecting to another url with java

<%@ page import="java.util.*" %>

<%
String source_url = "http://abc.blogspot.com/";
String target_url = "http://def.blogspot.com/";

String request_url = request.getRequestURL().toString();


if (request_url.equals(source_url))
{
      response.sendRedirect(target_url);
} else
{
out.println("Wrong URL");
}
%>

Comments

Popular posts from this blog