블로그 이미지
개발에 관한 것들.. 재만

카테고리

분류 전체보기 (66)
claztec's develop (1)
운영체제 (11)
프로그래밍 (41)
알고리즘 (0)
데이터베이스 (2)
소프트웨어공학 (3)
Books (2)
Total11,220
Today3
Yesterday9

css3 레퍼런스

분류없음 / 2010/02/24 00:44
http://www.veign.com/downloads/guides/qrg0008.pdf
저작자 표시 비영리 변경 금지
Posted by 재만

hudson 사용 정리

분류없음 / 2010/02/14 20:27
http://www.ibm.com/developerworks/kr/library/tutorial/j-cq11207/index.html
저작자 표시 비영리 변경 금지
Posted by 재만

subversive 설치

분류없음 / 2010/02/13 23:01
이클립스에 subversive 설치한것 정리.

설치환경
eclipse: galileo
OS: Ubuntu

Help에 Software Updates 에서 플러그인을 설치한다.

Location: http://download.eclipse.org/technology/subversive/0.7/update-site/


다른건 설치하지 않고 plugin만 설치한다. (어떤것을 설치해야 되는지 인터넷에서 검색한것 마다 다 맨아래 Subversive SVN team Provider Plugin 만 설치해도 잘 된다.)

설치가 끝나고 이클립스를 restart하게 된다. 이후 SVN을 사용하게 되면 Subversive Connector를 선택한다.
2가지 종류가 있는데 사용하는 os가 리눅스이기 때문에 선택의 여지없이 SVN Kit를 설치한다. java6를 사용하므로 SVN Kit 1.3.0 설치.


이상 Subversive 플러그인 설정 끝..
저작자 표시 비영리 변경 금지
Posted by 재만
테스트 하는데도 패턴이 있구나.

http://xunitpatterns.com/index.html
저작자 표시 비영리 변경 금지
Posted by 재만
DD(Deployment Descriptor) 파일로 쓰이는 web.xml에서 초기값을 정해 서블릿에 넘겨줄수있다.

ServletConfig와 ServletContext 를 사용할 수 있다.

ServletConfig는 컨테이너가 서블릿을 만들때 DD를 읽어 이름/값의 쌍으로 ServletConfig를 생성한다
서블릿이 다시 배포되지 않는 이상 DD를 수정한다고 바뀌지 않는다.

ServletContext는 서블릿만 사용하는 것이 아니라 모든 웹 어플리케이션에서 사용할 수 있다.

쉽게 말하면 ServletConfig는 서블릿 당 하나, ServletContext는 웹 어플리케이션 당 하나.

web.xml

더보기


TestInitParams.java

더보기


저작자 표시 비영리 변경 금지
Posted by 재만
Head First Servlet & JSP 에 설명된 초 간단 MVC

form.html 에서 form을 사용해서 request를 날리는데 서블릿이 받는다.
request를 받은 서블릿은 내부 처리를 한 후에 서블릿에서 바로 html을 그려주는게 아니라
view를 지정해 html을 그려준다

BeerSelect.java

더보기


서블릿에서 RequestDispatcher를 사용하는 점은 몰랐었다.
저작자 표시 비영리 변경 금지
Posted by 재만
TAG JSP
1. mod_jk 다운로드
http://tomcat.apache.org/download-connectors.cgi
1.2 소스를 다운로드 한다.
tomcat-connectors-1.2.28-src.tar.gz 파일임.

2. 설치
tomcat-connectors-1.2.28-src.tar.gz 압축을 풀고 BUILD.txt 를 통해 설치 ($>부분은 BUILD.txt에 나온 설명임)
$> cd native : native 디렉토리로 이동
claztec@claztec:/claztec/server/tomcat-connectors-1.2.28-src/native

$> ./configure --with-apxs=/usr/sbin/apxs (or where ever the apxs/apxs2 is) : 아파치에 apxs 위치를 확인한 후에 명령어를 실행한다.
claztec@claztec:/claztec/server/tomcat-connectors-1.2.28-src/native$ ./configure  --with-apxs=/claztec/server/httpd/bin/apxs

$> make
claztec@claztec:/claztec/server/tomcat-connectors-1.2.28-src/native/apache-2.0 에 mod_jk.so가 만들어 졌다.

$> su -c 'make install'
이 명령어를 안하고 수동으로 아파치 모듈에 mod_jk.so를 복사한다.
claztec@claztec:/claztec/server/tomcat-connectors-1.2.28-src/native/apache-2.0$ cp -p mod_jk.so /claztec/server/httpd/modules/

3. 설정
설정에 여러가지 방법이 있겠지만
http.conf 에서 mod_jk.conf 파일을 로드해서 worker.properties 를 읽어서 설정하도록 함.

http.conf 파일
Include conf/mod_jk.conf

mod_jk.conf 파일
Alias /examples/ "/claztec/server/tomcat/webapps/examples/"

<IfModule dir_module>
    DirectoryIndex index.html index.jsp
</IfModule>

<Directory "/claztec/server/tomcat/webapps/examples">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

LoadModule jk_module modules/mod_jk.so

#worker.properties 위치
JkWorkersFile "conf/worker.properties"
#로그 위치
JkLogFile "logs/mod_jk.log"
#로그 레벨
JkLogLevel info
#로그 문자열 포멧
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkRequestLogFormat "[%w %V %T]"

#url 매핑
JkMount /*.jsp worker1
JkMount /servlet/* worker1
#폴더에 관계없이 모든 jsp매핑

JKMount /* worker1

worker.properties 파일
worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009

4. 테스트
http://localhost/example 이 제대로 동작하는지 확인

저작자 표시 비영리 변경 금지
Posted by 재만
TAG mod_jk
리눅스 (우분투) 에서 자바 설치정리

1. 자바 다운로드
http://java.sun.com 에서 다운로드

java se development kit(jdk) 을 다운로드 하고 bin 파일을 받는다. (우분투에 설치할 것이므로.)


2. 설치
/usr/local 에 설치할 것이다.

다운받은 jdk-6u17-linux-i586.bin 파일을 /usr/local에 옮긴다. /usr/local은 root 그룹이어서 sudo 사용.
claztec@claztec:/usr/local$ sudo mv /home/claztec/Downloads/jdk-6u17-linux-i586.bin .

파일에 실행권한을 준다
claztec@claztec:/usr/local$ chmod +x jdk-6u17-linux-i586.bin

파일을 실행 (sudo로)
claztec@claztec:/usr/local$ sudo ./jdk-6u17-linux-i586.bin

설치를 하겠다고 yes를 누르면 설치 완료. /usr/local/jdk1.6.0_17 가 생긴다.

/usr/local/java로 쓸 수 있도록 심볼릭 링크를 걸어준다
claztec@claztec:/usr/local$ sudo ln -s jdk1.6.0_17/ java

/etc/profile에 path를 정한다
claztec@claztec:/usr/local$ sudo vi /etc/profile

#JAVA_HOME
JAVA_HOME=/usr/local/java
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/*

이후 로그아웃 한후 다시 로그인을 하면 적용된다.
터미널에서 java, javac 를 쳐보고 나오면 설치 완료
저작자 표시 비영리 변경 금지
Posted by 재만
http://httpd.apache.org/ 에서 다운 2.2 가 최신
설치는 공식 문서에 잘 나와있음.
http://httpd.apache.org/docs/2.2/install.html

내가 원하는 위치에 설치를 하기 원하므로
$./configure --prefix=/claztec/server/httpd/
이렇게 설정해주면 /claztec/server/httpd/에 설치된다

설치후 bin/apachectl start (root로) 실행한 후에 http://localhost 에서 It works ! 가 뜨는지 확인.
바로 실행하면 에러가 나는데 conf/httpd.conf 에서 ServerName을 안적어서 그런다.
도메인이 있으면 도메인을 적고 없으면 127.0.0.1:80 을 적어주면 된다.

아파치에서 띄우고 싶은 html 파일은 htdocs 에 넣어준다.
저작자 표시 비영리 변경 금지
Posted by 재만
TAG apache
Thinking in Java solution 4th ..

okjsp 에서 구함. http://www.okjsp.pe.kr/seq/144468

이 책은 참 안 읽힌다.
저작자 표시 비영리 변경 금지
Posted by 재만
http://pcandme.net/66?category=7

갈릴레오로 바꿨더니 클릭이 안된다. 키보드로 엔터를 쳐야됨.. ㅡㅡ;;
저작자 표시 비영리 변경 금지
Posted by 재만
http://kldp.org/node/71058
http://www.solanara.net/solanara/tomcat
저작자 표시 비영리 변경 금지
Posted by 재만
message of the day

/etc/motd 에서 수정

로그인 이후 보이는 문구

http://jyong.net/6
저작자 표시 비영리 변경 금지
Posted by 재만
mysql 설치
http://dev.mysql.com/doc/refman/5.1/en/installing-binary.html

1. mysql 다운
wget 을 사용해서 다운.
커뮤니티서버 5.1 Linux (non RPM packages) downloads

mysql-5.1.41-linux-i686-glibc23.tar.gz



2. mysql 계정 만들기. - root를 안쓰고 mysql 이라는 계정으로 mysql을 관리한다.

mkdir /home/mysql
groupadd -g 300 mysql
useradd -u 300 -g 300 -d /home/mysql -s /bin/bash mysql
chown mysql:mysql /home/mysql

3. 다운받은 mysql 을 /user/local로 이동 후 chown을 통해 mysql:mysql로 변경.
이렇게 만들어 준다.
mysql@ubuntu:/usr/local$ ls -l
합계 36
drwxr-xr-x  2 root  root  4096 2009-10-10 15:20 bin
drwxr-xr-x  2 root  root  4096 2009-10-10 15:20 etc
drwxr-xr-x  2 root  root  4096 2009-10-10 15:20 games
drwxr-xr-x  2 root  root  4096 2009-10-10 15:20 include
drwxr-xr-x  3 root  root  4096 2009-10-10 15:20 lib
lrwxrwxrwx  1 root  root     9 2009-10-10 15:20 man -> share/man
lrwxrwxrwx  1 root  root    32 2009-10-25 10:47 mysql -> mysql-5.1.40-linux-i686-glibc23/
drwxr-xr-x 13 mysql mysql 4096 2009-10-07 05:28 mysql-5.1.40-linux-i686-glibc23
drwxr-xr-x  2 root  root  4096 2009-10-10 15:20 sbin
drwxr-xr-x  5 root  root  4096 2009-10-10 15:34 share
drwxr-xr-x  2 root  root  4096 2009-10-10 15:20 src
mysql@ubuntu:/usr/local$

4. configure
/usr/local/mysql/support-files/my-large.cnf 파일을 /etc/my.cnf 로 이름을 바꾸어서 복사해준다.
./scripts/mysql_install_db --defaults-file=/etc/my.cnf --user=mysql 실행 해준다.

mysql@ubuntu:/usr/local/mysql$ ./scripts/mysql_install_db --defaults-file=/etc/my.cnf --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h ubuntu password 'new-password'

Alternatively you can run:
./bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!

The latest information about MySQL is available at http://www.mysql.com/
Support MySQL by buying support/licenses from http://shop.mysql.com/


5. mysql 띄우기
mysql 계정으로 사용자를 변경 한 후에 ./mysqld_safe --user=mysql & 이렇게 mysql을 띄운다.

mysql@ubuntu:/usr/local/mysql/bin$ ./mysqld_safe --user=mysql &
[1] 25969
mysql@ubuntu:/usr/local/mysql/bin$ 091025 10:59:20 mysqld_safe Logging to '/usr/local/mysql/data/ubuntu.err'.
091025 10:59:20 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

6. mysql 접속
mysql을 실행하면 끝..

7. 몇 몇 문제해결
mysql@claztec:/usr/local/mysql/bin$ ./mysqladmin stop
./mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!

mysqld.sock 없다고 에러가 나는데
/var/run 에 mysqld (mysql:mysql) 을 만들어주고
/etc/my.cnf 에서 mysqld.sock 경로를 다시 잡아주니 잘 되었다
#socket         = /tmp/mysqld.sock
socket          = /var/run/mysqld/mysqld.sock

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

또 추가로 발생한 문제점.
 
부팅할때마다 /var/run/mysqld가 사라진다.
/var/run/mysqld를 /tmp로 심볼릭 링크해 주었다.


너무 대충 보고 정리해서 나중에 보면 뭔 말인지 모를수 있겠다.


저작자 표시 비영리 변경 금지
Posted by 재만
TAG MySQL
http://zicman.egloos.com/2449683
저작자 표시 비영리 변경 금지
Posted by 재만
http://channy.creation.net/project/html5/html4-differences/Overview_ko.html
저작자 표시 비영리 변경 금지
Posted by 재만

base css

프로그래밍/CSS / 2009/10/04 21:24
body {margin:0;padding:0;background-color:#fff;text-align:center;}     
	/* 배경 color 필수, 가운데 정렬 레이아웃 */
hr {display:none;}    
	/* 레이아웃이나 큰 콘텐츠 그룹 구분(top/left/contents/footer)에 적용 */
img,fieldset {border:0 none;}      
dl,ul,ol,li {list-style: none;}      
h1,h2,h3,h4,h5,dl,dt,dd,ul,li,ol,th,td,
p,blockquote,form,fieldset,legend {margin:0;padding:0;}
table {border-collapse:collapse;}
a {text-decoration:none;}
a:link:hover, a:active {text-decoration:underline;}    
	/* 엘리먼트가 링크일때만(href 속성을 가질때만) underline이 생긴다. */
input,select,textarea {font-size:100%;}
body,th,td {font-size:12px;font-family:"굴림",gulim,sans-serif;color:#333;}    
	/* font설정은 해당 서비스에 맞게 변경가능. */
저작자 표시 비영리 변경 금지
Posted by 재만
TAG css
한글을 써보려고 하니 잘 안된다..

http://www.javajigi.net/pages/viewpage.action?pageId=1054

이방법도 잘 안됨.
저작자 표시 비영리 변경 금지
Posted by 재만
69-language-selector-ko-kr.conf
한글 언어팩 설치후 터미널 폰트가 이상할때..
저작자 표시 비영리 변경 금지
Posted by 재만
spring에서 view로 jsp 파일을 사용하고 jstl을 사용할때 아래와 같은 에러가 발생하였다.

According to TLD or attribute directive in tag file, attribute items does not accept any expressions

첫 페이지에서만 에러가 발생하고 새로고침을 하게 되면 정상적으로 보였다.

<%@ taglib prefix = "c" uri = "http://java.sun.com/jstl/core" %>
로 설정이 되어 있었던게 문제였고
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
로 수정하니 문제없이 보였다
1.0을 1.1로 수정해서 문제해결.

http://happybruce.tistory.com/185?srchid=BR1http%3A%2F%2Fhappybruce.tistory.com%2F185

저작자 표시 비영리 변경 금지
Posted by 재만
okjsp에서 발견한 글.

http://www.okjsp.pe.kr/seq/131181

저작자 표시 비영리 변경 금지
Posted by 재만
http://www.cs.stevens.edu/~jschauma/765-APUE/
저작자 표시 비영리 변경 금지
Posted by 재만
http://www.thinkonweb.com/seminar/ajax/index.jsp
저작자 표시 비영리 변경 금지
Posted by 재만
CSS 비밀 메뉴얼 예제가 있는 사이트.

http://www.sawmac.com/missing/css/
저작자 표시 비영리 변경 금지
Posted by 재만
TAG css
스프링 프레임워크  다운로드
http://www.springsource.org/download

스프링 플러그인 설치
이클립스 플러그인설치에 http://springide.org/updatesite 주소를 추가.
Dependencies, Integration 항목은 제외..
저작자 표시 비영리 변경 금지
Posted by 재만
애자일 자바 첫장.

테스트 주도 개발로 자바를 배우자는게 애자일 자바의 핵심인것 같다. 다른 책들과 다르게 예제를 따라하고, 연습문제를 풀어야 제대로 책을 보았다고 할 수 있는 책이다.

책에는 JetBrains의 IDEA를 사용해서 예제를 실행하는 방법에 대해 소개되어 있다. 하지만 대세는 이클립스란 생각에 이클립스를 사용해서 예제와 연습문제를 풀었다.

환경설정을 잘 해야 개발에 집중할 수 있는데, 환경설정이 잘 안되면 짜증만 나고 의욕이 떨어진다.

환경은 Windows XP에서 Java 1.6, Eclipse Galileo, JUnit 4 이다.
Java를 설치하고 환경변수를 설정하는것은 이야기 하지 않는다.
이클립스는 갈릴레오를 설치하였고, 이클립스에 JUnit이 기본적으로 들어있다.
해줘야 할 것은 Java Build Path의 Libraries에 JUnit을 추가해주면 된다.

아래에서 보이는 이클립스 화면과 같이 Package Explorer에서 JUnit4가 추가된 모습이 보이게 해야한다.


이클립스에서 Java Project를 만든다.
프로젝트에서 오른쪽 클릭 > Properties 를 클릭한다
Java Build Path > Libraries > Add Library 를 선택해서 JUnit을 추가한다.



JUnite을 선택한다.



JUnit3와 JUnit4를 선택할 수 있는데 JUnit4를 선택하였다.


환경설정은 간단히 이것으로 끝이 난다.

자바 소스의 위치는 src와 test로 나뉘는데 src는 실제 자바 코드가 들어가는 곳이고 test는 JUnit 테스트 자바 코드가 들어가는 곳이다. New > Source Folder 로 소스폴더를 추가하면 된다. New > Folder 로 추가하면 Java Build Path > Source에서 해당 폴더를 추가해 줘야 bin 디렉토리에 class 파일이 생성된다.


연습문제

PawnTest.java

더보기


Pawn.java

더보기


저작자 표시 비영리 변경 금지
Posted by 재만
head first 디자인 패턴에 대한 정리가 되어 있다.
http://wiki.oracleclub.com/pages/viewpage.action?pageId=1507372

wikipedia 디자인 패턴 카테고리. GOF 디자인패턴 외에 많은 패턴이 소개되어 있다.
http://en.wikipedia.org/wiki/Category:Software_design_patterns
저작자 표시 비영리 변경 금지
Posted by 재만
영어로 이해하는 연습을 하자..
이것도 다 수련..

http://en.wikipedia.org/wiki/Command_pattern

객체지향프로그래밍에서 커맨드 패턴은 객체가 메소드를 부를때 필요한 정보를 캡슐화하여 나타내는 디자인 패턴이다.
객체는 메소드와 메소드 파라미터의 값을 갖는다.

커맨드 패턴은 client, invoker, receiver 3가지가 연관되어 있다. 클라이언트(client)는 커맨드 객체를 사용하고, 이후 메소드를 부를때 사용되는 정보를 제공한다. 인보커(호출자, invoke:부르다는 의미)는 메소드가 불릴때 결정된다. 리시버는 메소드 코드가 포함된 클래스의 인스턴스다.

커맨드 패턴을 만들면 위임, 순차나 메소드 실행이 필요한 공통 컴포넌트를 쉽게 만들수 있다. 이때 해당 메소드의 주인이나, 메소드 파라미터를 알 필요가 없다.

사용
Undo
사용자 액션은 스택에 쌓게 되고 그것을 꺼내면 undo가 된다.

트랜잭셔널 행위
롤백이나 자동으로 수행되다 실패했을때 undo는 필수로 있어야 하는데 커맨드 오브젝트는 two-phase commit 을 구현하는데 사용된다.

프로그래스 바
순차적으로 선택된 커맨드들을 실행시키는 프로그램이 있을때, 커맨드에 getEstimateDuration() 메소드를 정의하면 이것을 사용해 프로그래스 바에 반영할 수 있다.

위저드 (마법사)
GUI프로그램에서 "Finish" 를 선택했을때 자동으로 실행되는 프로그램을 만드는데 사용된다.

GUI 버튼, 메뉴 아이템
Swing에서 Action이 커맨드 객체이다.

쓰레드 풀
보통 쓰레드 풀이 가지고 있는 addTask() 메소드를 가지고 있는데 큐에 task를 더하는 방식으로 되어 있다. 큐에 있는 아이템들이 커맨드 객체.

매크로
사용자 액션이 커맨드 객체로 되어 있다면 이것을 기억해서 같은 액션을 수행할 수 있게 된다.

네트워크
컴퓨터 네트워크 게임처럼 입력한 커맨드를 네트워크를 통해 다른 머신에서 실행시킨다.

병렬 프로세싱
커맨드들이 자원을 공유하고 많은 쓰레드를 병렬적으로 실행하기 위해 쓰인다.

구조


예제
/*the Invoker class*/
public class Switch {
 
    private Command flipUpCommand;
    private Command flipDownCommand;
 
    public Switch(Command flipUpCmd,Command flipDownCmd){
         this.flipUpCommand=flipUpCmd;
         this.flipDownCommand=flipDownCmd;
    }
 
    public void flipUp(){
         flipUpCommand.execute();
    }
 
    public void flipDown(){
         flipDownCommand.execute();
    }
 
}
 
 
/*Receiver class*/
 
public class Light{
 
     public Light(){  }
 
     public void turnOn(){
        System.out.println("The light is on");
     }
 
     public void turnOff(){
        System.out.println("The light is off");
     }
 
}
 
/*the Command interface*/
 
public interface Command{
    void execute();
}
 
 
/*the Command for turning on the light*/
 
public class FlipUpCommand implements Command{
 
   private Light theLight;
 
   public FlipUpCommand(Light light){
        this.theLight=light;
       }
 
   public void execute(){
      theLight.turnOn();
   }
 
}
 
 
 
/*the Command for turning off the light*/
 
public class FlipDownCommand implements Command{
 
   private Light theLight;
 
   public FlipDownCommand(Light light){
        this.theLight=light;
       }
 
   public void execute(){
      theLight.turnOff();
   }
 
}
 
/*The test class or client*/
public class PressSwitch{
 
   public static void main(String[] args){
       Light lamp = new Light();
       Command switchUp=new FlipUpCommand(lamp );
       Command switchDown=new FlipDownCommand(lamp );
 
       Switch s=new Switch(switchUp,switchDown);
 
       try {
           if (args[0].equalsIgnoreCase("ON")){
                s.flipUp();
                System.exit(0);
           }
           if (args[0].equalsIgnoreCase("OFF")){
               s.flipDown();
               System.exit(0);
           }
           System.out.println("Argument \"ON\" or \"OFF\" is required.");
           } catch (Exception e){
            System.out.println("Argument's required.");
           }
 
   }
}





예제에서 보여준 심플 스위치는 불을 키고 끄는 두가지 커맨드가 있다. 커맨드 패턴을 사용하면서 얻게 되는 장점은 스위치를 꼭 불을 끄고 키는데 사용하는게 아니라 엔진(engine)을 키고 끄는 것처럼 다른 것에도 적용할 수 있다는 것이다.

Command : Command.java
ConcreteCommand : FlipDownCommand.java, FilpUpCommand.java
Receiver : Light.java
Invoker : Switch.java
Client : PressSwitch.java

더보기


저작자 표시 비영리 변경 금지
Posted by 재만
3가지 스크립트 요소

스크립트릿
자바코드를 실행할때 사용
<%
    자바 코드1;
    자바 코드2;
%>

표현식
어떤 값을 생성한 HTML 문서 결과값에 포함시키고자 할때
<%= 값 %>

선언부
JSP 페이지의 스크립트릿이나 표현식에서 사용할 수 있는 함수를 작성할 때 사용
<%!
    public int multiplay(int a, int b) {
        int c = a * b;
        return c;
    }
%>

쉽게 정리하면 자바 코드를 JSP 페이지에서 사용하고 싶으면 <% %> 안에서 사용하면 된다. 간단한 자바 변수에 값을 html에 뿌려주려면 <%= %>를 사용하면 되고, 함수를 선언해서 사용하고 싶으면 <%! %>를 사용한다.
저작자 표시 비영리 변경 금지
Posted by 재만
TAG JSP
page 디렉티브

 속성 설명
기본값
 language JSP 스크립트 코드에서 사용되는 프로그래밍 언어 지정
"java"
 contentType JSP가 생성할 문서의 타입을 지정
"text/html"
 import JSP페이지가 사용할 자바 클래스 지정
 
 session  JSP 페이지가 세션을 사용할지 지정. "true"/"false"
"true"
 buffer  JSP 페이지의 출력 버퍼 크기 지정. "none" 사용하지 않음. "8kb" 8킬로바이트 사용
최소 8kb
 autoFlush  출력버퍼가 다 찼을때 자동으로 버퍼에 있는 데이터를 출력 스트림에 보내고 비울지 여부 "true"/"false"
"true"
 info  JSP 페이지에 대한 설명 입력
 
 errorPage  JSP 페이지를 실행하는 도중에 에러가 발생할 때 보여줄 페이지 지정
 
 isErrorPage  현재 페이지가 에러가 발생할 때 보여지는 페이지여부 지정. "true"/"false"
"false"
 pageEncoding  JSP 페이지 캐릭터 인코딩 지정
 
 isELIgnored  "true" 표현언어 지원. "false" 표현언어 미지원
web.xml에서 사용하는 JSP 버전 및 설정에 따라 다름
(자주사용하는 contentType / page 속성 설명)

contentType 속성 / 캐릭터 셋
한글
<%@ page contentType="text/html; charset="euc-kr" %>
유니코드
<%@ page contentType="text/html; charset="UTF-8" %>

import 속성
JSP 페이지에서 자바의 클래스를 사용하기 위해 자바 클래스를 지정
<%@ import = "java.util.Calendar" %>
<%@ import = "java.util.Date" %>

,와 *를 사용해 간략하게 사용할 수 있다.
<%@ import = "java.util.Calendar, java.util.Date" %>
<%@ import = "java.util.*" %>

※ import 속성에서 클래스를 지정한 후 사용하지 않고 스크립트릿에서 클래스를 선언해 사용할 수 있다.


저작자 표시 비영리 변경 금지
Posted by 재만
TAG JSP

최근에 달린 댓글

최근에 받은 트랙백

글 보관함