1: …… 2: protected void doGet(HttpServletRequest request, HttpServletResponse response) 3: throws ServletException, IOException { 4: String query = request.getQueryString(); 5: 6: // 다른 페이지 이동하는 URL 리스트를 만든다. 7: String allowURL[] = { "url1", "url2", "url3" }; 8: ArrayList arr = new ArrayList(); 9: for ( int i = 0; i < allowURL.length; i++ ) 10: arr.add(allowURL[i]); 11: 12: if (query.contains("url")) { 13: String url = request.getParameter("url"); 14: // url에 대한 유효성 점검을 한다. 만약 http://가 있으면 다른 도메인으로 URL을 redirect로 의심된다. 15: if (url != null && url.indexOf("http://") != -1 ) { 16: url = url.replaceAll("\r", "").replaceAll("\n", ""); 17: // URL 목록에 있지 않으면 요청을 거부한다. 18: if ( !arr.contains(url) ) throw new MyException("에러“); 19: response.sendRedirect(url); 20: } 21: } 22: ……