2009년 8월 31일 월요일

About Native XMLHTTP

Ref. : About Native XMLHTTP

XMLHTTP in IE7 vs. IE6

The native implementation of the XMLHTTP object is designed with cross-browser compatibility in mind. With just a bit of script, it is easy to build a function that works with either version of Internet Explorer, or any browser that supports XMLHTTP. See XMLHttpRequest for complete documentation and examples.

var xmlHttp = null;
if (window.XMLHttpRequest) {
// If IE7, Mozilla, Safari, and so on: Use native object.
xmlHttp = new XMLHttpRequest();
}
else
{
if (window.ActiveXObject) {
// ...otherwise, use the ActiveX control for IE5.x and IE6.
xmlHttp = new ActiveXObject('MSXML2.XMLHTTP.3.0');
}
}

VI에서 대소문자 변환하기

대소문자 반전 키
~ (물결 무늬) 키를 누르면 현재 커서가 위치한 글자 1개의 대소문자가 반전됩니다. 대문자는 소문자로, 소문자는 대문자로 변경됩니다.

키보드 가장 왼쪽에 ~ 이렇게 물결 무늬처럼 생긴 "틸데(Tilde)" 키가 있습니다. Shift키를 누르면서 `(백틱)키를 누르면 ~가 찍힙니다.



한 줄을 모두 대문자로 변환하는 명령어
gUU 라는 명령을 주면, 현재 커서가 위치한 줄이 모두 대문자로 변경됩니다.


한 줄을 모두 소문자로 변환하는 명령어
guu 라는 명령을 주면, 현재 커서가 위치한 줄이 모두 소문자로 변경됩니다.



선택 영역(블록)의 대소문자 변경
v 키를 누릅니다. (vim 에디터 화면 맨 밑에 --VISUAL-- 이라는 글자가 나와야 합니다.) 참고: ▶▶ Vim (Vi)에디터] 블록 선택, 복사, 붙이기; Select Copy Paste

이제 shift-화살표 키를 눌러 텍스트의 특정 부분만 선택합니다.

소문자 u 를 누르면, 선택 영역의 모든 알파벳이 소문자로 변경됩니다.

대문자 U 를 누르면, 선택 영역의 모든 알파벳이 대문자로 변경됩니다.

2009년 8월 28일 금요일

Resource Injection using Annotation - Java EE5

In web application.

 

      Container-managed object에만 사용할 수 있다.

            - container가 생성을 관리할 수 있어야 injection을 할 수있기 때문.

            - 따라서 일반 Javabean에서는 사용할 수 없다. 그러나 JavaServer Faces에서 사용하는 bean에는 사용할 수 있다.

 

      Resource injection JSP에 사용할 수 없다.

            - Resource Injection을 위한 annotaion deployment time에 적용되기 때문에 JSP에서는 사용할 수 없다.

 

Table 3-1 Web Components That Accept Resource Injections

Component

Interface/Class

Servlets

javax.servlet.Servlet

Servlet Filters

javax.servlet.ServletFilter

Event Listeners

javax.servlet.ServletContextListener

javax.servlet.ServletContextAttributeListener

javax.servlet.ServletRequestListener

javax.servlet.ServletRequestAttributeListener

javax.servlet.http.HttpSessionListener

javax.servlet.http.HttpSessionAttributeListener

Taglib Listeners

Same as above

Taglib Tag Handlers

javax.servlet.jsp.tagext.JspTag

Managed Beans

Plain Old Java Objects

 

Declaring Resource References

 

@Resource annotation deployment descriptor 내의 resource-ref element와 동일하다.

 

@Resource javax.sql.DataSource catalogDS;

public getProductsByCategory() {

// get a connection and execute the query

Connection conn = catalogDS.getConnection();

..

}

 

@Resources ({
    @Resource (name="myDB" type=java.sql.DataSource),
    @Resource(name="myMQ" type=javax.jms.ConnectionFactory)
})

 

 

Declaring a Reference to a Web Service

The @WebServiceRef annotation provides a reference to a web service. The following example shows uses the @WebServiceRef annotation to declare a reference to a web service. WebServiceRef uses the wsdlLocation element to specify the URI of the deployed services WSDL file:

...
import javax.xml.ws.WebServiceRef;
...
public class ResponseServlet extends HTTPServlet {
@WebServiceRef(wsdlLocation=
    "http://localhost:8080/helloservice/hello?wsdl")
static HelloService service;

JSP EL(expression language)에서 사용하는 객체들

The JSP expression language defines a set of implicit objects:

■ pageContext: The context for the JSP page. Provides access to various objects including:
■ servletContext: The context for the JSP page’s servlet and any web components contained in the same application. See “Accessing the Web Context” on page 124.
■ session: The session object for the client. See “Maintaining Client State” on page 125.
■ request: The request triggering the execution of the JSP page. See “Getting Information from Requests” on page 110.
■ response: The response returned by the JSP page. See “Constructing Responses” on page 112.
■ In addition, several implicit objects are available that allow easy access to the following objects:
■ param:Maps a request parameter name to a single value
■ paramValues:Maps a request parameter name to an array of values
■ header:Maps a request header name to a single value
■ headerValues:Maps a request header name to an array of values
■ cookie:Maps a cookie name to a single cookie
■ initParam:Maps a context initialization parameter name to a single value
■ Finally, there are objects that allow access to the various scoped variables described in “Using Scope Objects” on page 105.
■ pageScope:Maps page-scoped variable names to their values
■ requestScope:Maps request-scoped variable names to their values
■ sessionScope:Maps session-scoped variable names to their values
■ applicationScope:Maps application-scoped variable names to their values

DB2에서 CODESET을 지정하여 새로운 DB만들기

db2 create db mywiki  USING CODESET UTF-8 TERRITORY KR

Windows에서 기본 설정으로 만들면 CODEPAGE와 CODESET이 1363으로 지정되어 JDBC 연결 사용시 UnsupportedEncodingException : Cp1363C 에러가 발생함.

Linux에 truetype font설치

ttf등 true type font를 복사하고,

cd /usr/local/fonts/ttf
ttmkfdir > fonts.scale
mkfontdir

리눅스에 DB2 설치하기

DB2 v9.5 필요 조건  

https://publib.boulder.ibm.com/infocenter/db2luw/v9r5/index.jsp?topic=/com.ibm.db2.luw.qb.server.doc/doc/r0008865.html

SLES에 대한 패키지 요구사항 패키지 이름 설명
libaio DB2 서버에 필요한 비동기 라이브러리를 포함합니다.
compat-libstdc++ libstdc++so.5를 포함합니다.

RHEL에 대한 패키지 요구사항
디렉토리 패키지 이름 설명
/시스템 환경/라이브러리 libaio DB2 서버에 필요한 비동기 라이브러리를 포함합니다.
/시스템 환경/라이브러리 compat-libstdc++ libstdc++so.5를 포함합니다.

DB2 v9 필요 조건

http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.uprun.doc/doc/r0008865.htm

Samba 공유 설정 - 폴더 권한 설정

[data]
path = /home/samba/data
browseable = yes
guest ok = yes
writeable = yes
create mask = 744
valid users = admin mikimous
while the directory mask option shown here will force the permissions of a newly created directory to be at most 755:

[data]
path = /home/samba/data
browseable = yes
guest ok = yes
writeable = yes
directory mask = 755
Alternatively, you can also force various bits with the force create mode and force directory mode options. These options will perform a logical OR against the file and directory creation masks, ensuring that those bits that are specified will always be set. You would typically set these options globally in order to ensure that group and world read/write permissions have been set appropriately for new files or directories in each share.
In the same spirit, if you wish to explicitly set the Unix user and group attributes of a file that is created on the Windows side, you can use the force user and force group options. For example:

[data]
path = /home/samba/data
browseable = yes
guest ok = yes
writeable = yes

create mask = 744
directory mask = 755
force user = joe
force group = accounting

DB2 BLOB 처리방법

저장 방법
ByteArrayOutputStream과 OjbectInputStream을 이용하여
저장하고자 하는 내용( 자바 객체 )를 byte array로 serialize한다. ( writeObject )사용
변환된 byte array를 DB2LobFactory를 이용하여 create 한다.

ByteArrayOutputStream bo = new ByteArrayOutputStream(2048);
ObjectOutputStream oo = new ObjectOutputStream(bo);
oo.writeObject(msg.getArgs());
stmt.setBlob(++index, DB2LobFactory.createBlob( bo.toByteArray() ));
oo.close();
bo.close();


조회 방법

동일한 sql문을 사용하여 조회 후 ResultSet의 getBlob을 이용하여 꺼낸다음.
ByteArrayInputStream과 ObjectInputStream을 이용하여 Object로 변환 후 원하는 객체로 캐스팅 한다.

Blob blob =  rset.getBlob(++index);
//System.out.println(rset.getInt(1)+"blob : "+blob );
if( blob != null ){
// System.out.println(blob.getBytes(1L,(int)blob.length()));
ByteArrayInputStream bin = new ByteArrayInputStream( blob.getBytes(1L,(int)blob.length()) );
ObjectInputStream oin = new ObjectInputStream( bin );
Object[] args = (Object[])oin.readObject();
for( int i=0; args!=null &&  i < args.length; i++ ){
if( args[i] == null ) continue;
out.println(args[i].getClass().getName()+":");out.println( args[i] ); out.println("<br>");
}
oin.close();
bin.close();
}

꽂지 일몰