FileDocCategorySizeDatePackage
SiteSelector.javaAPI DocExample943Tue Jan 25 10:45:14 GMT 2000None

SiteSelector

public class SiteSelector extends HttpServlet

Fields Summary
Vector
sites
Random
random
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)

    res.setContentType("text/html");
    PrintWriter out = res.getWriter();

    int siteIndex = Math.abs(random.nextInt()) % sites.size();
    String site = (String)sites.elementAt(siteIndex);

    res.setStatus(res.SC_MOVED_TEMPORARILY);
    res.setHeader("Location", site);
  
public voidinit(javax.servlet.ServletConfig config)


        
    super.init(config);
    sites.addElement("http://www.oreilly.com/catalog/jservlet");
    sites.addElement("http://www.servlets.com");
    sites.addElement("http://jserv.java.sun.com");
    sites.addElement("http://www.servletcentral.com");