2008년 10월 20일 월요일

JSP: html tag strip

tartgetString.replaceAll("\\<.*?\\>", "")

그냥 정규식으로 처리해버렸다. 100% 신뢰 할수 없는 방법이지만....

2008년 10월 12일 일요일

HTML: scroll css


<style type="text/css">
div.contxt {
scrollbar-3dlight-color:white;
scrollbar-arrow-color:gray;
scrollbar-base-color:black;
scrollbar-darkshadow-color:black;
scrollbar-face-color:black;
scrollbar-highlight-color:white;
scrollbar-shadow-color:white;
}
</style>

2008년 10월 1일 수요일

JAVA: NAVER OPEN MAP & HTTP CLIENT

적당히 아래와 같이 쓸 수도 있겠다.
JSP 페이지도 적당히 만들어서 적당히 IMPORT하여 쓰는 방법이 오히려 더 편할 것 같기도 하지만..
뭐.. 적당히 적당히...


<%
String adress = request.getParameter("adress");
adress = URLDecoder.decode(adress, "utf-8");

HttpClient client = new HttpClient();
PostMethod httppost = new PostMethod("http://maps.naver.com/api/geocode.php");
//한글 처리를 위한 헤더 셋팅
httppost.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded; charset=euc_kr");
DefaultMethodRetryHandler retryhandler = new DefaultMethodRetryHandler();
retryhandler.setRequestSentRetryEnabled(false);
// retry 시도 실패 했을때..
retryhandler.setRetryCount(3);
httppost.setMethodRetryHandler(retryhandler);
httppost.addParameter("key", "naver api key");
httppost.addParameter("query",adress);

try {
client.executeMethod(httppost);
if (httppost.getStatusCode() == HttpStatus.SC_OK) {
String bodyString = httppost.getResponseBodyAsString();
//System.out.println(httppost.getResponseBodyAsString());

XStream xStream = new XStream(new DomDriver());

xStream.alias("geocode",GeoCode.class);
xStream.alias("item",Item.class);
xStream.addImplicitCollection(GeoCode.class, "items");

GeoCode geoCode = (GeoCode)xStream.fromXML(bodyString);
String result = ((Item)geoCode.getItems().get(0)).getPoint().toJson();
out.print(result);
System.out.print("result : " + result);
} else {
System.out.println("Unexpected failure: "
+ httppost.getStatusLine().toString());
}
} finally {
httppost.releaseConnection();
}

%>