LevSelector.com New York
home > http, cgi, cookies

Redirect in Perl, Java & Javascript

- html
- perl
- java
- javascript

HTML home - top of the page -

put this tag in the header, change 0 to number of seconds if you want to wait:
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=http://www.yahoo.com">

Perl home - top of the page -

#! /usr/local/bin/perl
print "Location: http://www.yahoo.com\n\n";
# print "Status: 301 Redirect\nLocation: http://www.yahoo.com\n\n";

Java Servlets home - top of the page -

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
// import java.util.*;
// import java.sql.*;

public class rr1 extends HttpServlet {
  public void init(ServletConfig config) throws ServletException {
    super.init(config);
  }

  public void doPost( HttpServletRequest req, HttpServletResponse res ) throws ServletException,
IOException {
    res.setContentType("text/html");
    PrintWriter out = new PrintWriter (res.getOutputStream());
    res.sendRedirect("http://www.LevSelector.com");

/*
 or you can do this:
   out.println(<html><META HTTP-EQUIV="Refresh" CONTENT="0;URL=http://www.yahoo.com"></html>);
 or these 2 lines:
   res.setStatus(res.SC_MOVED_TEMPORARILY);
   res.setHeader("Location", "http://www.yahoo.com");
*/

  }

  public void doGet( HttpServletRequest req, HttpServletResponse res ) throws ServletException,
IOException {
    doPost(req,res);
  }

}

Javascript home - top of the page -

<a href="javascript:document.location='http://www.yahoo.com'">jump2yahoo</a>
or shorter
<a href="javascript: location='http://www.yahoo.com'">jump2yahoo</a>
jump2yahoo