1: public class U247 extends HttpServlet { 2: public void doGet(HttpServletRequest req, HttpServletResponse res) 3: throws ServletException, IOException { 4: boolean trusted = false; 5: String ip = req.getRemoteAddr(); 6: 7: // 호스트의 IP 주소를 얻어온다. 8: InetAddress addr = InetAddress.getByName(ip); 9: 10: // 호스트의 IP정보와 지정된 문자열(trustme.com)이 일치하는지 검사한다. 11: if (addr.getCanonicalHostName().endsWith(" trustme.com" ) ) { 12: trusted = true; 13: } 14: if (trusted) { 15: …… 16: } else { 17: …… 18: } 19: } 20: }