1 25 package org.snipsnap.net; 26 27 import org.snipsnap.snip.SnipSpace; 28 import org.snipsnap.snip.Snip; 29 import org.snipsnap.container.Components; 30 import org.snipsnap.config.Configuration; 31 32 import javax.servlet.ServletException ; 33 import javax.servlet.http.HttpServlet ; 34 import javax.servlet.http.HttpServletRequest ; 35 import javax.servlet.http.HttpServletResponse ; 36 import java.io.IOException ; 37 import java.io.PrintWriter ; 38 39 45 public class RobotServlet extends HttpServlet { 46 47 protected void doGet(HttpServletRequest request, HttpServletResponse response) 48 throws ServletException , IOException { 49 String name = request.getHeader("User-Agent"); 50 String host = request.getRemoteHost(); 51 52 SnipSpace space = (SnipSpace) Components.getComponent(SnipSpace.class); 53 if(space.exists(Configuration.SNIPSNAP_CONFIG_ROBOTS_TXT)) { 54 Snip robotstxt = space.load(Configuration.SNIPSNAP_CONFIG_ROBOTS_TXT); 55 PrintWriter writer = new PrintWriter (response.getOutputStream()); 56 writer.println(robotstxt.getContent()); 57 writer.flush(); 58 } else { 60 response.sendError(HttpServletResponse.SC_NOT_FOUND); 61 } 62 } 63 } 64 | Popular Tags |