JAVA2013. 6. 28. 11:25

출처-Http 송수신 HttpClient 

 

POST 방식 예제

01 import org.apache.commons.httpclient.HttpClient;
02 import org.apache.commons.httpclient.HttpStatus;
03 import org.apache.commons.httpclient.methods.PostMethod;
04
05 import java.io.BufferedReader;
06 import java.io.InputStreamReader;
07
08 public class PostMethodExample {
09 public static void main(String args[]) {
10 HttpClient client = new HttpClient();
11 client.getParams().setParameter("http.useragent", "Test Client");
12 BufferedReader br = null;
13 PostMethod method = new PostMethod("http://search.yahoo.com/search");
14 method.addParameter("p", "\"java2s\"");
15 try{
16 int returnCode = client.executeMethod(method);
17
18 if(returnCode == HttpStatus.SC_NOT_IMPLEMENTED) {
19 System.err.println("The Post method is not implemented by this URI");
20 // still consume the response body
21 method.getResponseBodyAsString(); 
22 } else {
23 br = new BufferedReader(newInputStreamReader(method.getResponseBodyAsStream()));
24 String readLine;
25 while(((readLine = br.readLine()) != null)) {
26 System.err.println(readLine);
27 }
28 }
29 } catch (Exception e) {
30 System.err.println(e);
31 } finally {
32 method.releaseConnection();
33 if(br != null) try { br.close(); } catch (Exception fe) {}
34 }
35 }

결과 받는 다른 예제)

byte[] responseBody = method.getResponseBody();
   method.getRequestEntity();
   String xml = new String(responseBody);

   SAXBuilder builder = new SAXBuilder();
   Document doc = builder.build(new StringReader(xml));
   Element root = doc.getRootElement();

String ResponseValue = root.getChild("ResponseValue").getValue();
   

Posted by 선한열심
JSP2013. 6. 27. 23:14

리소스 properties 파일 이용하기

3가지 방법 

1. fmt bundle 이용
<fmt:setLocale value="ko_KR"/>
<fmt:setBundle basename="resource" var="lang" />
<fmt:message key="fruits.apple" bundle="${lang}" />
</body>
</html>

파일 위치는 /WEB-INF/src바로 밑에

* resource.properties

fruits.apple=apple
fruits.strawberry=strawberry
fruits.banana=banana

 

 

2. 프로젝트 \WEB-INF\web.xml  안에 추가할수도 있네요

  <context-param>
  <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
  <param-value>JeongMessageBundle</param-value>
</context-param>

파일위치 : classes\JeongMessageBundle.properties

 

3. JSP 에서 사용

Copy properties file in WEB-INF/classes folder

Suppose we have file commonVariable.properties in WEB-INF/classes folder

# forum path and properties
forum.path=forum
forum.url=forum
forum.database=jspforum
forum.use=yes

JSP which is getting values from ResourceBundle properties file

resource.jsp

<%@ page language="java" import="java.util.*" %>
<%
ResourceBundle resource = ResourceBundle.getBundle("commonVariable");
/// commonVariable.properties file will be in WEB-INF/classess  folder

String sPath=resource.getString("forum.path");
String sName=resource.getString("forum.database");

System.out.println(sPath);
System.out.println(sName);

%>

 

Posted by 선한열심
JAVA2013. 6. 26. 17:41

 

[출처] System.getProperty(시스템 환경변수)|작성자 joypheonix

1. set

1) System.getProperty(key, defaultvalue.) 사용    : key 가 null 일때 defaultvalue값을 가져옴 

 ( 참고 : http://www.tutorialspoint.com/java/lang/system_getproperty_string_def.htm )

2) was(tomcat, jeus...)별로 <command-option>에

-Dkey값 = value값 설정

예) jeus

-->

<engine-container>
<name>container6</name>
<command-option>-Xms256m -Xmx512m
-Djplug.home=D:/eclipse_workspace/FFI/WebContent/jplugreport/license
</command-option>
<engine-command>
<type>servlet</type>
<name>engine6</name>
</engine-command>
</engine-container>

 예) JBOSS 서버 예

1) 이클립스 서버더블클릭

2) Open launch configuration 클릭

3) Arguments 에   -Dkey값 = value값 설정

 

 

2. get

// Get the value of the system property
String prop = System.getProperty("jplug.home);
// my value

3. 기본 저장 키

System.getProperty("java.version") : java.version=1.6.0_17

System.getProperty("java.home") : java.home=C:\jdk1.6.0_17\jre

System.getProperty("java.vendor") : java.vendor=Sun Microsystems Inc.

System.getProperty("java.specification.version") : java.specification.version=1.6

System.getProperty("os.name") : os.name=Windows 7

System.getProperty("os.arch") : os.arch=x86

System.getProperty("user.country") : user.country=KR

System.getProperty("user.name") : user.name=saint

System.getProperty("user.language") : user.language=ko

System.getProperty("file.encoding") : file.encoding=MS949

System.getProperty("file.separator") : file.separator=\

System.getProperty("path.separator") : path.separator=;

------------------------------------

Property 정보를 확인하는 자바 소스

------------------------------------

import java.util.Enumeration;
import java.util.Properties;

public class TestProperty {
public static void main(String[] args) {
Properties sysprops = System.getProperties();
for (Enumeration e = sysprops.propertyNames(); e.hasMoreElements();) {
String key = (String) e.nextElement();
String value = sysprops.getProperty(key);
System.out.println(key + "=" + value);
}
}
}

 

'JAVA' 카테고리의 다른 글

[Configuration] 설정  (0) 2013.07.01
Http 송수신 HttpClient  (0) 2013.06.28
for문 ":" 정리  (0) 2013.06.25
[펌]xpath 를 이용, java 에서 xml 문서 쉽게 파싱하기  (0) 2013.06.13
Log4j 로그 두번찍히는 문제  (0) 2013.06.05
Posted by 선한열심
이클립스2013. 6. 26. 16:44

[출처] Jad 환경설정 (이클립스 설정)|작성자 홀리데이s

** jad와 ecilpse plugin 다운로드 **

 

[]

Posted by 선한열심
Oracle2013. 6. 26. 11:00

[오라클] 테이블 인덱스, 컬럼, 커멘트 정보 얻는 쿼리

'Oracle' 카테고리의 다른 글

[Oracle-펌] Over 함수  (0) 2013.07.31
재귀쿼리  (0) 2013.07.29
LISTAGG WITHIN GROUP  (0) 2013.06.25
[펌][Oracle] 부정형(NOT IN, <>, NOT EXISTS ...)의 비교  (0) 2013.06.18
[Toad] formatter 단축키  (0) 2013.06.05
Posted by 선한열심
Oracle2013. 6. 25. 18:04


    DEPTNO ENAME
---------- ----------
        20 SMITH
        30 ALLEN
        30 WARD
        20 JONES
        30 MARTIN
        30 BLAKE
        10 CLARK
        20 SCOTT
        10 KING
        30 TURNER
        20 ADAMS
        30 JAMES
        20 FORD
        10 MILLER
 

    DEPTNO EMPLOYEES
---------- --------------------------------------------------
        10 CLARK,KING,MILLER
        20 SMITH,FORD,ADAMS,SCOTT,JONES
        30 ALLEN,BLAKE,MARTIN,TURNER,JAMES,WARD
       
       
SELECT deptno, LISTAGG(ename, ',') WITHIN GROUP (ORDER BY ename) AS employees
FROM   emp
GROUP BY deptno;

    DEPTNO EMPLOYEES
---------- --------------------------------------------------
        10 CLARK,KING,MILLER
        20 ADAMS,FORD,JONES,SCOTT,SMITH
        30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD

Posted by 선한열심
JQuery2013. 6. 25. 15:32

 출처 - http://blog.naver.com/PostView.nhn?blogId=ggugers&logNo=10151692442

 

jquery_tr이동.html

<table>
<tr id="header"><td>header</td></tr>
<tr id="tr_1"><td><input type="radio" name="del" value="1">1</td></tr>
<tr id="tr_2"><td><input type="radio" name="del" value="2">2</td></tr>
<tr id="tr_3"><td><input type="radio" name="del" value="3">3</td></tr>
<tr id="tr_4"><td><input type="radio" name="del" value="4">4</td></tr>
<tr id="tr_5"><td><input type="radio" name="del" value="5">5</td></tr>
<tr id="tr_6"><td><input type="radio" name="del" value="6">6</td></tr>
<tr id="tr_7"><td><input type="radio" name="del" value="7">7</td></tr>
</table>
<input type="button" value="up" onclick="moveRowUpDown('up')">
<input type="button" value="down" onclick="moveRowUpDown('down')">

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
function moveRowUpDown(option) {
 var num = $('input[name=del]:checked').val();
 if(num==undefined){
  alert("select radio");
  return;
 }
 var element = $("#tr_"+num);
 if(option=="up"){
  if( element.prev().html() != null  && element.prev().attr("id") != "header"){
   element.insertBefore(element.prev());
  }
 }else{
        if( element.next().html() != null ){
            element.insertAfter(element.next());
        }
 }
}
</script>

'JQuery' 카테고리의 다른 글

on 함수  (0) 2013.07.18
jquery 그래프  (0) 2013.07.16
이벤트 생성 및 발생  (0) 2013.07.16
자주사용하는 것들 정리  (0) 2013.05.14
[펌]jQuery IE 버전에 Placeholder 적용하기  (0) 2013.04.04
Posted by 선한열심
JAVA2013. 6. 25. 11:09

핵심 : for 문에서 countryList 루프를 돌때

         countryVO.setCarriers 하면 countryList에 추가하여 countryList.get(0).getCarriers() 값이 추가된다

       주소값을 전달해서 그런거 같다

 

예제)
        List<CountryVO> countryList = DAO.getCountry(ID);        

List<String> countryCodeList = new ArrayList<String>();
if ( countryList != null ) {

       for ( CountryVO countryVO : countryList ) 
       {
            if ( countryVO.getCarrierCount() > 0 ) { 
              countryVO.setCarriers(this.DAO.getCountryCarriersNew(CountryVO.getCountryCode(), CountryVO.getID()));
                }
        }
 }

Posted by 선한열심
자바스크립트2013. 6. 20. 10:19

new Ajax.Request

Posted by 선한열심
JAVA OPEN API2013. 6. 19. 18:20

네이버  : "sitemesh(사이트메쉬) 해보기" 검색하면 나옴

http://cafe.naver.com/buldon/2005

 

1. jar파일 다운로드 ( http://opensymphony.com/  프로젝트 임 )

  http://www.sitemesh.org/ - > download  ( sitemesh-버전.jar , 최신 2.4.2 )

 

2. web.xml 설정 추가

 <!-- Sitemesh Configration -->
 <filter>
  <filter-name>sitemesh</filter-name>
  <filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>
 </filter>
 <filter-mapping>
  <filter-name>sitemesh</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>

3. /WEB-INF/decorators.xml 설정

 <?xml version="1.0" encoding="UTF-8"?>
<decorators defaultdir="/decorators">
    <decorator name="basic-theme" page="basic-theme.jsp">
        <pattern>/data/*</pattern>
    </decorator>
</decorators>

4. basic-theme.jsp 파일

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Café Mirabeau</title>
</head>
<body>
    <h1>Header</h1>
    <p><b>Navigation</b></p>   
    <hr />
    <decorator:body />    
    <hr />
    <h1>Footer</h1>
</body>
</html>

 

5. /data/hour.jsp      ( 화면에 보일때는 basic-theme.jsp 안에 hour.jsp파일의 body가 자동으로 들어가서 보인다 )

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Hours</title>
</head>
<body>
    <h1>Weekdays</h1>
    <p>5:00pm - 10:00pm</p>
    <p>Weekends</p>
    <p>5:00pm - 10:00pm</p>
</body>
</html>

 

sitemesh에서 제공하는 파일   cafe.war

Posted by 선한열심