1: public class S247 extends HttpServlet { 2: 3: public void doGet(HttpServletRequest req, HttpServletResponse res) 4: throws ServletException, IOException { 5: 6: String ip = req.getRemoteAddr(); 7: if ( ip == null || "".equals(ip) ) 8: return ; 9: 10: String trustedAddr = "127.0.0.1"; 11: 12: if (ip.equals(trustedAddr) ) { 13: …… 14: } else { 15: …… 16: } 17: } 18: }