08
Jan
08

301 Redirect for JSP / Java

To do a 301 redirect on JSP pages simple modify this code for your own purposes and place it on the page you want to redirect:

<%
response.setStatus(301);
response.setHeader( “Location”, “http://www.new-url.com/” );
response.setHeader( “Connection”, “close” );
%>


However, my favorite method of doing 301 redirects is still the htaccess file.

Other 301 redirect methods:

301 redirects for PHP
301 redirects for ASP.NET
301 redirects for classic ASP


2 Responses to “301 Redirect for JSP / Java”


  1. 1 Dorita May 18th, 2009 at 5:23 am

    Hello,
    thank you for the info.

    I use the published code in my jsp but I have an error 404.

    “…Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.”

    Do I need to create the html file first?

  2. 2 saptak mandal Sep 6th, 2010 at 12:25 pm

    .htaccess is the best option actually it have a lot more ..a lot of thing can be managed using htaccess

Leave a Reply




local business directories

Linkage