<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">

  <SCRIPT LANGUAGE="JavaScript">
  <!--
var num="";var won=new Array;var obj="";
function num2won(val){
    re=/[^0-9]+/g
    num=val.toString();
    if(!val) {alert("내용이 없습니다.");return false;}
    if(re.exec(num)) {alert("숫자만 입력 가능합니다.");return false;}
    if(num.substr(0,1)==0) {alert("0으로 시작할수 없습니다.");return false;}
    var price_unit0=new Array("","일","이","삼","사","오","육","칠","팔","구");
    var price_unit1=new Array("","십","백","천");
    var price_unit2=new Array("만","억","조","경","해");
    for(i=0;i<=num.length-1;i++){won[i]=price_unit0[num.substr(i,1)];}
    won=won.reverse();
    for(i=0;i<=num.length-1;i++){if(i>0 && won[i]!="") {won[i]+=price_unit1[i%4];}}
    for(i=4;i<=won.length-1;i=i+4) {won[i]+=price_unit2[(i/4-1)];}
    for(i=0;i<=num.length-1;i++){if(i%4 > 0) {won[i]=won[i].replace("일","");}}
    won=won.reverse();return won.join("");
 
}

function test() {
 alert(num2won(42258.0));
}

  //-->
  </SCRIPT>
 </HEAD>

 <BODY onclick="test()">
 
 </BODY>
</HTML>

function calulateFloatingPoint( _num01, _num02, type ) {
    var T = Number('1e'+1);
    var result = 0;
    var num01  = (_num01 * T)/T;
    var num02  = (_num02 * T)/T;

    // Multiply
    if( type == "M") {
        result = num01*num02;
    } 
    // Plus
    else  if( type == "P") {
        result = num01+num02;
    }   
    return result.toFixed(2); // 소수점 자리수
}

Jdk 1.5 + tomcat 5.5 + 이클립스 갈릴레오 + mysql Toad

1. Jdk 1.6을 컴퓨터에 설치 (ex) d:\내디렉토리\java\jre6)

2. Jdk 1.5 d:\내디렉토리\java\에 복사

3. tomcat 5.5 설치. 주의사항은 jre6를 잡지 말고 jdk1.5를 기본

java로 잡도록 설정

4. 시스템 변수에서

CATALINA_HOME - d:\p\tomcat;

JAVA_HOME - d:\p\jdk1.5.0_15;

PATH - d:\p\tomcat\bin;%JAVA_HOME%\bin;

5. 이클립스 설치

그냥 압축 해제후(d:\p\) 이클립스 바로가기를 만든다.

이때 이클립스 바로가기 속성 모드에서

아래와 같이 설정을 하여준다.

d:\p\eclipse\eclipse.exe -vm "d:\P\Java\jdk1.5.0_15\bin\javaw"

 

[이클립스 실행파일에 추가하여야 할 문자열]

D:\ProjectJava\tools\JDK\jdk1.5.0_15\bin\javaw -vmargs -Xverify:none -XX:+UseParallelGC -XX:PermSize=64M -XX:MaxPermSize=128M -XX:MaxNewSize=32M -XX:NewSize=32M -Xmx512M

다른 방법으로 하는 것은 아래 사이트 참조

http://3rabbitz.textcube.com/entry/Eclipse-start-Error-%ED%95%B4%EA%B2%B0%ED%95%98%EA%B8%B0-JVM-terminated-Exit-code-1

workspace 설정은 알아서 각자..

저는 workspace 약자로 "d:\p\w"로 설정.

6.이클립스에서 톰캣 설정시

Windows-Preference-Server-Runtime Environments에서

add를 누르고 설치되어진 톰캣 5.5를 설정. 그 후 톰캣 디렉토리 설정후 완료

왼쪽 탐색기에서 New를 하고 Dynaminc web project를 클릭하여

프로젝트명을 써주고 Target runtime에 톰캣 지정후 finish.

톰캣이 밑에 Server로 등록되어지지 않으면 Server에서 오른쪽버튼클릭. New에서 Server로 새로운 서버를 생성해준다 .

이때에 아까 Target runtime을 지정해주었던 프로젝트명이 있게 되는데 그것을 add를 해주어야 함.

http://iamnotokay.tistory.com/26
http://tools.netshiftmedia.com/regexlibrary/#
        <%-- 마우스 오른쪽 버튼 --%> 
        $(document)[0].oncontextmenu = function() {return false;}
        <%-- F5버튼 처리 --%> 
        $(document.body).keydown(
            function(e) {
                if ( e.which == "116") {
                    agent = jQuery.browser;
                    if(agent.msie) {
                        e.cancelBubble = true;
                    } else {
                        e.stopPropagation();
                    }
                }
            }
        );

window.showModalDialog(sURL[,vArguments][,sFeatures])

vArguments 는 윈도우 객체가 들어갈 수 있으며,


sFeatures 모달창의 속성을 지정한다.


속성은 다음과 같다.


dialogHeight:sHeight Sets the height of the dialog window (see Remarks for default unit of measure).
dialogLeft:sXPos Sets the left position of the dialog window relative to the upper-left corner of the desktop.
dialogTop:sYPos Sets the top position of the dialog window relative to the upper-left corner of the desktop.
dialogWidth:sWidth Sets the width of the dialog window (see Remarks for default unit of measure).
center:{ yes | no | 1 | 0 | on | off } Specifies whether to center the dialog window within the desktop. The default isyes.
dialogHide:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window is hidden when printing or using print preview. This feature is only available when a dialog box is opened from a trusted application. The default isno.
edge:{ sunken | raised } Specifies the edge style of the dialog window. The default israised.
help:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window displays the context-sensitive Help icon. The default isyes.
resizable:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window has fixed dimensions. The default isno.
scroll:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window displays scrollbars. The default isyes.
status:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window displays a status bar. The default isyesfor untrusted dialog windows andnofor trusted dialog windows.
unadorned:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window displays the border window chrome. This feature is only available when a dialog box is opened from a trusted application. The default isno.


팝업창에서의 부모창을 컨트롤 하는 객체 - dialogArguments ( window.open의 opener와 같은 의미 )

모달창에서 submit()을 하면 새창이 뜨게 되는데, 새창을 뜨지 않게 하는 방법은 다음과 같다.


<head>
<base target="_self" />
</head>

head tag에 <base target="_self" />를 넣으면 된다.



# sample
 var attr = "dialogHeight=480px; dialogWidth=550px; scroll=auto; status=yes; help=no; center=yes";  
 var url = "action.do";
 window.showModalDialog(url, window, attr); 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/yuiloader/yuiloader-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/json/json-min.js"></script>

</HEAD>

<BODY onclick="test()">

</BODY>
</HTML>
<SCRIPT LANGUAGE="JavaScript">
<!--
function test() {
var jsonString = '{  "category" : [';
jsonString +='{ "animal" : "Cat",  "message" : "Meow"  },';
jsonString +='{ "animal" : "Dog",  "message" : "Woof"  },';
jsonString +='{ "animal" : "Cow",  "message" : "Moo"   },';
jsonString +='{ "animal" : "Duck", "message" : "Quack" },';
jsonString +='{ "animal" : "Lion", "message" : "Roar"  }';
jsonString +='] }';
 
// Parsing JSON strings can throw a SyntaxError exception, so we wrap the call
// in a try catch block
try {
    var prod = YAHOO.lang.JSON.parse(jsonString);
 alert(prod.category[1].animal);
}
catch (e) {
    alert("Invalid product data");
}

}
//-->
</SCRIPT>


지금 제가 하고 있는 프로젝트에서는 데이터를 넘길거나 받을때 JSON을 사용하고 있습니다.

약간의 제약이 있긴 하지만 일단 가볍고 쉽기때문에 선택했죠.

요 JSON을 자바스크립트에서 파싱해서 사용하기는 참 쉽습니다.

무식하게 eval() 함수를 사용해도 좋고 아니면 prototype.js나 mootool.js 와 같은 자바스크립트 프레임워크를 사용한다면 거기서 지원하는 함수를 사용하면 쉽고 깔끔합니다.

문제는 자바에서 파싱하는 문제인데 요것땜시 거의 두시간이나 헤맸습니다.

http://www.json.org 에 들어가보시면 많은 JSON 툴들을 보실수 있습니다.

자바스크립트 툴은 여기서 제공하는것보다는 위에서 설명한 프레임워크에서 제공하는 툴을 사용하는게 더 나은듯 싶습니다.

 


요렇게 많군요


Java 에서 많이 사용하는게 조~기 보이는 Json-lib 하고(http://json-lib.sourceforge.net/)
org.json.simple(http://www.json.org/java/simple.txt, 다운로드: http://www.JSON.org/java/json_simple.zip ) 입니다. 대부분 두가지를 많이 쓰더군요.

 Json-lib 의 경우 정말 많은 기능을 제공합니다. 그만큼 복잡하긴 하지만 이건 될듯해 라고 생각하고 해보면 진짜로 된다는... 신기하더군요.

반면에 org.json.simple은 단순하고 사용자가 자주 쓰는 기능 위주로 되있습니다.

어차피 대부분의 경우JSONObject 객체와 JSONArray 이외의 클래스는 사용하지 않기때문에 간단하게 사용하려면 아래의 simple을 사용하면 되겠습니다.

차이는 있습니다.

Map testMap = new HashMap();
testMap.put("k1" , "v1");
JSONObject jo = new JSONObject();
jo.put("a0", "b0");
jo.put("a1", testMap);


이 결과를 수행하면 org.json.simple은
{"a0":"b0", "a1":{"k1=v1"}} 이렇게 됩니다.
Map으로 넣을경우 제대로 변환이 안된걸 알수 있습니다.

반면 Json-lib 은 {"a0":"b0", "a1":{"k1":"v1"}} 으로 나옵니다.
 
참고로 툴마다 객체명이나 메소드 명이 다르므로 꼭 확인 하고 쓰는 센스!!!


위에서 javascript에서 파싱하는 방법은... 이야기 안했지만 찾아보면 더럽게 많이 나옵니다.

근데 java에서 파싱하는 내용은 찾기가 어렵더군요.

org.json.simple에서는 욜케 하면 된답니다.

String s="[0,{\"1\":{\"2\":{\"3\":{\"4\":[5,{\"6\":7}]}}}}]";
  Object obj=JSONValue.parse(s);
  JSONArray array=(JSONArray)obj;
  System.out.println(array.get(1));
  JSONObject obj2=(JSONObject)array.get(1);
  System.out.println(obj2.get("1"));

  Result:
  {"1":{"2":{"3":{"4":[5,{"6":7}]}}}}
  {"2":{"3":{"4":[5,{"6":7}]}}}


그럼 Json-lib 에서는???

JSONObject jo = JSONObject.fromObject("{\"aa\":\"bb\"}");
이렇게 하면 됩니다.

jo.toString() => {"aa":"bb"}
jo.get("aa") => bb

이렇게 되더군요.

이상입니다. 별것도 아닌 내용인데 저는 왜이리 찾아 헤맸는지...


출처 : http://merongworld.tistory.com


웹 브라우져에서 간단한 Java Script를 실행하여 테스트 해 볼 수 있는 Java Script 쉘을 소개합니다.

1. 파이어 폭스 홈페이지에 가서 파이어폭스를 다운받아 설치합니다.

파이어폭스 다운로드

2. 파이어폭스를 설치하고 쉘 스크립트 바로가기를 만들기 위해 아래의 사이트로 이동합니다.

http://www.squarefree.com/shell/


3. 상단에 두개의 링크 ( Open the Shell, get the Shell bookmarklet ) 중 get the Shell bookmarklet를 클릭합니다.

4. 다음과 같이 여러종류의 bookmarklet중 shell , jsenv 둘중에 하나를 선택하여 사용하면 됩니다.


5. shell 북마켓을 드레그하여 Fire Fox의 즐겨찾기 메뉴에 드래그하여 링크를 추가 합니다.


6. 링크를 클릭하면 다음과같은 스크립트 실행창이 보입니다.



 

+ Recent posts