<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %> <%@ page import="java.net.*, java.io.*" %> <% String NL = System.getProperty("line.separator"); String sReqType = request.getParameter("req_type"); String sUrl = request.getParameter("url"); if( sReqType == null || sReqType.equalsIgnoreCase("null") ) { sReqType = "GET"; } if( sUrl == null || sUrl.equalsIgnoreCase("null") ) { sUrl = ""; } StringBuffer contents = new StringBuffer(); if( !sUrl.equals("") ) { try { URL url = new URL(sUrl); contents.append(">> URL(" + sUrl + ") Connecting...").append(NL); HttpURLConnection uc = (HttpURLConnection)url.openConnection(); uc.setDoOutput(true); uc.setDoInput(true); uc.setUseCaches(false); uc.setRequestMethod(sReqType); StringBuffer sb = new StringBuffer(); InputStream is = uc.getInputStream(); contents.append(">> Reading Contents...").append(NL); BufferedReader in = new BufferedReader(new InputStreamReader(is)); int buffSize = 1024 * 8; char[] buff; int insize = 0; while ((insize = in.read(buff = new char[buffSize], 0, buffSize)) != -1) { sb.append((new String(buff, 0, insize))); } String receivestr = sb.toString().trim(); contents.append(">> Contents").append(NL); contents.append("------------------------------------------").append(NL); contents.append(sb.toString().trim()).append(NL); contents.append("------------------------------------------").append(NL); contents.append(">> End").append(NL); } catch(FileNotFoundException fnfe){ contents.append(">> FileNotFoundException").append(NL); contents.append("------------------------------------------").append(NL); contents.append(fnfe.getMessage()).append(NL); contents.append("------------------------------------------").append(NL); contents.append(">> End").append(NL); fnfe.printStackTrace(); } catch(Exception e){ contents.append(">> Exception").append(NL); contents.append("------------------------------------------").append(NL); contents.append(e.getMessage()).append(NL); contents.append("------------------------------------------").append(NL); contents.append(">> End").append(NL); e.printStackTrace(); } } %> URL 확인

Check URL

REQ TYPE
URL
Result