<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.io.*,java.util.*,java.net.*"%>

<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Stream Test</title>

</head>
<body>

<%
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");

URL tempURL;
//tempURL = new URL("http://article.joinsmsn.com/news/list/list.asp?mc=2000001&cloc=joins|navi_top|opinion_sasul");
tempURL = new URL("http://www.koreaherald.com/");

String line;
String a = tempURL.getHost();

out.println(a);
%>
잡았습니다 :)
<%
BufferedReader br = new BufferedReader(new InputStreamReader(tempURL.openStream(), "utf-8"));

while ((line = br.readLine()) != null) {

 out.print(line + "\n"); //뉴라인 넣지 않으면 주석등에 코드 가려짐..

}
%>
</body>
</html>


출처 : http://www.okjsp.pe.kr/seq/172748

+ Recent posts