설명을 안써서...
매뉴얼에 나와있지만 써본다.
Apache Ant is a Java-based build tool. In theory, it is kind of like make, without make's wrinkles.

사실 설치하는 것을 설명할 필요는 없다.
http://ant.apache.org/manual/index.html
매뉴얼이 친절하게 알려준다.

여기서 중요한 점은 환경변수 설정인데
- Add the bin directory to your path.
- Set the ANT_HOME environment variable to the directory where you installed Ant. On some operating systems, Ant's startup scripts can guess ANT_HOME (Unix dialects and Windows NT/2000), but it is better to not rely on this behavior.
라고 나와있다.
PATH에 빈디렉터리를 추가해주고 ANT_HOME을 만들어서 ANT의 경로를 추가해주면 된다.
도스창에 들어가서 ant를 치면 메시지가 띡-하고 뜬다. 그 다음에 버전을 체크하면 버전표시가 띡-하고 뜬다.

그 다음 중요한 점은 buildfile 작성하기.
ant의 빌드파일은 xml로 되어있다.

빌드파일의 예제

<project name="MyProject" default="dist" basedir=".">
    <description>
        simple example build file
    </description>
  <!-- set global properties for this build -->
  <property name="src" location="src"/>
  <property name="build" location="build"/>
  <property name="dist"  location="dist"/>

  <target name="init">
    <!-- Create the time stamp -->
    <tstamp/>
    <!-- Create the build directory structure used by compile -->
    <mkdir dir="${build}"/>
  </target>

  <target name="compile" depends="init"
        description="compile the source " >
    <!-- Compile the java code from ${src} into ${build} -->
    <javac srcdir="${src}" destdir="${build}"/>
  </target>

  <target name="dist" depends="compile"
        description="generate the distribution" >
    <!-- Create the distribution directory -->
    <mkdir dir="${dist}/lib"/>

    <!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
    <jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/>
  </target>

  <target name="clean"
        description="clean up" >
    <!-- Delete the ${build} and ${dist} directory trees -->
    <delete dir="${build}"/>
    <delete dir="${dist}"/>
  </target>
</project>

http://pcguy7.springnote.com/pages/546569
다음에 올라온 예제를 실행해본 결과,

Buildfile: E:\project\ztest\WebContent\build.xml
prepare:
     [echo] Build Start!! ======> 2009.03.04-10:41
clean:
   [delete] Deleting directory E:\project\ztest\WebContent\dist
compile:
    [mkdir] Created dir: E:\project\ztest\WebContent\build
mkjar:
    [mkdir] Created dir: E:\project\ztest\WebContent\dist
      [jar] Warning: skipping jar archive E:\project\ztest\WebContent\dist\1.0_helloprint.jar because no files were included.
      [jar] Building MANIFEST-only jar: E:\project\ztest\WebContent\dist\1.0_helloprint.jar
dist:
     [copy] Copied 1 empty directory to 1 empty directory under E:\project\ztest\WebContent\dist\lib
     [copy] Copied 1 empty directory to 1 empty directory under E:\project\ztest\WebContent\dist\src
      [zip] Building zip: E:\project\ztest\WebContent\2009.03.04_1.0_helloprint.zip
BUILD SUCCESSFUL
Total time: 203 milliseconds
경고만 빼면...그럭저럭 돌아가는 듯하다.
Posted by zeide
,

[게시판] 글 조회수

자료 2009. 3. 2. 10:00
...
Connection con = null;
PreparedStatement pstmt = null;
...

try{
...(커넥션 얻기)
StringBuffer addCount = new StringBuffer();
addCount.append("update board set readcount = readcount+1 where num=?");
pstmt = con.prepareStatement(addCount.toString());
pstmt.setInt(1,num);
pstmt.executeUpdate();
...
}
...

이것은 누구나 아는 방법.
보통 글 번호에 따른 게시물을 읽는 코드와 같이 쓴다.(파라미터로 글 번호를 받기 때문에)
Posted by zeide
,
1. 쿠키 심기
  Cookie cookie = new Cookie(name, value);
  cookie.setMaxAge(limit);
  cookie.setPath("/");
  response.addCookie(cookie);

2.쿠키 얻기
Cookie[] cookies = request.getCookies();
  String str = "";
  
  if(cookies!=null){
   for(int i=0;i<cookies.length;i++){
    if(ckname.equals(cookies[i].getName())){
     str = URLDecoder.decode(cookies[i].getValue(),"utf-8");
    }//if
   }//for
  }//if

Posted by zeide
,

[게시판] 페이징2

자료 2009. 2. 17. 11:24

게시판이나 방명록 하단에 보이는 페이지 넘기기 부분

public class MyUtil {
// 현재 게시판의 페이지 인덱스 설정
    public String indexList(int current_page, int total_page, String list_url) {
        int pagenumber;     // 화면에 보여질 페이지 인덱스 수
        int startpage;      // 화면에 보여질 시작페이지 번호
        int endpage;        // 화면에 보여질 마지막페이지 번호
        int curpage;        // 이동하고자 하는 페이지 번호
        String strList="";  // 리턴될 페이지 인덱스 리스트

        pagenumber = 3;    // 한 화면의 페이지 인덱스 수 

        // 시작 페이지번호 구하기
        startpage = ((current_page - 1) / pagenumber) * pagenumber + 1;
        // 마지막 페이지번호 구하기
        endpage = (((startpage - 1) +  pagenumber) / pagenumber) * pagenumber;

        // 총 페이지 수가 계산된 마지막페이지 번호보다 작을경우
        // 총 페이지 수가 마지막페이지 번호가 됨
        if (total_page <= endpage)
        {
            endpage = total_page;
        }

        // 첫번째 페이지 인덱스 화면이 아닌경우
        if ( current_page > pagenumber) {
            curpage = startpage - 1;    // 시작페이지 번호보다 1 적은 페이지로 이동
            strList = strList + "<a href='"+list_url+"&current_page="+curpage+"'>[<<]</a>";
        }else{
            strList = strList + "[<<]";
        }
        strList = strList + " ... ";

        // 시작페이지 번호부터 마지막페이지 번호까지 화면에 표시
        curpage = startpage;

        while (curpage <= endpage){
            if (curpage == current_page) {
                strList = strList + "["+current_page+"]";
            } else {
                strList = strList +"<a href='"+list_url+"&current_page="+curpage+"'>["+curpage+"]</a>";
            }
            curpage++;
        }
        strList = strList + " ... ";
     
        // 뒤에 페이지가 더 있는경우
        if ( total_page > endpage) {
            curpage = endpage + 1; 
            strList = strList + "<a href='"+list_url+"&current_page="+curpage+"'>[>>]</a>";
        }else{
            strList = strList + "[>>]";
        }
        return strList;
    }
}

Posted by zeide
,
댓글을 다는 게시판에서 설정해야 할 부분

1. 글 순서 변수
2. 그룹화를 위한 변수
3. 어느 글에 대한 답글인지의 변수
4. 그룹에 대한 순서를 지어줄 수 있는 변수

이 중에서 2, 3, 4를 추가한다.
Posted by zeide
,

[게시판] 페이징1

자료 2009. 2. 13. 12:09

게시판 하단에 페이지 넘기기 부분.
주석 참고.

public class PagingHandle {
 private int p_group;//화면에 보이는 페이지의 그룹
 /**
  * @param page_url
  * @param total_page
  * @param page_size
  * @param page_num
  * @return
  */
 public String indexPageList(String page_url, String total_page, String page_size, int page_num ){
  String reIndexList="";//반환되는 페이징
  
  int totalRow = Integer.parseInt(total_page);//전체 글의 수
  int pageSize = Integer.parseInt(page_size);//한 페이지에 보여질 글의 수
  int pageNum = page_num;//페이지 번호
  
  /*시작 페이지 번호(보여지는 페이지의 번호) 구하기
   * 보고 있는 페이지가 페이지 그룹의 마지막 페이지면(pageNum==p_group) 다음 페이지를시작 페이지로 설정 */
  int startPage = ((((pageNum%p_group)==0)?pageNum-1:pageNum)/p_group)*p_group+1;
  
  /*전체 페이지 번호 구하기
   *전체 글의 수를 페이지당 보여질 글의 수로 나누면 총 페이지가 나온다. 글 수가 많으면 1페이지 추가 */
  int totalPage = (totalRow/pageSize)+(((totalRow%pageSize)==0)?0:1);
  
  /*마지막 페이지 번호 구하기
   *전체 페이지 번호에서 보여지는 페이지 번호를 제외한 나머지 페이지와 페이지그룹을 비교해서 결정 */
  int endPage = ((totalPage-startPage)<p_group)?totalPage:p_group;
  
  //1번 페이지로 가기
  reIndexList +="<a href='"+page_url+"&pageNum=1'>[처음]</a>&nbsp";
  
  //현재 페이지가 페이지 그룹보다 클 경우 이전 그룹으로 가기
  if(pageNum>p_group){
   reIndexList +="<a href='"+page_url+"&pageNum="+(startPage-1)+"'>[이전]</a>&nbsp";
  }//if
  
  //페이지 그룹 안에 있는 페이지 번호 설정하기
  while(startPage<=endPage){
   //현재 보고 있는 페이지
   if(startPage==pageNum){
    reIndexList+="<b>["+pageNum+"]</b>&nbsp";
   }else{
    reIndexList+="<a href='"+page_url+"&pageNum="+startPage+"'>["+startPage+"]</a>&nbsp";
   }//else
   startPage++;
  }//while
  
  //뒤에 페이지가 더 있으면 다음 페이지 그룹으로 가기
  if(endPage!=totalPage){
   reIndexList +="<a href='"+page_url+"&pageNum="+(endPage+1)+"'>[다음]</a>&nbsp";
  }//if
  
  //마지막 페이지로 가기
  reIndexList +="<a href='"+page_url+"&pageNum="+totalPage+"'>[끝]</a>";
  
  return reIndexList;
 }//indexPageList
 
}//class
Posted by zeide
,

[게시판] web.xml 설정

자료 2009. 2. 10. 17:17
web.xml에서 매핑설정
 
<filter>
  <filter-name>encodingFilter</filter-name>
  <filter-class>
   org.springframework.web.filter.CharacterEncodingFilter
  </filter-class>
  <init-param>
   <param-name>encoding</param-name>
   <param-value>UTF-8</param-value>
  </init-param>
 </filter>
 
 <filter-mapping>
  <filter-name>encodingFilter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>
 
 <servlet>
  <servlet-name>guestboard</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <init-param>
   <param-name>contextConfigLocation</param-name>
   <param-value>/WEB-INF/config.xml,
        /WEB-INF/controller.xml
   </param-value>
  </init-param>
 </servlet>
 
 <servlet-mapping>
  <servlet-name>guestboard</servlet-name>
  <url-pattern>*.htm</url-pattern>
 </servlet-mapping>

Posted by zeide
,
DB는 오라클10g

>테이블<
create table guestbook(
num number(4) not null primary key,
name varchar2(20) not null,
pass varchar2(20) not null,
reg_date varchar2(10) not null,
subject varchar2(50) not null,
content varchar2(4000) not null,
readcount number(4) not null,
re_step number(4) not null,
re_level number(4) not null,
ref number(4) default 0
);

>num증가를 위한 시퀀스<
create sequence guest_bookno
start with 1
increment by 1
minvalue 1
maxvalue 9999999
;
Posted by zeide
,

먼저, 이클립스과 톰캣은 설치를 해두어야 한다.
(사양 : 이클립스 v3.4 과 톰캣 v5.5)

1. 플러그인 받기
eclipsetotale.com
프랑스 사이트이지만 영어로 친절하게 설명이 다 써 있다. :D

2. 플러그인 설치하기
이클립스가 설치된 폴더 중 plugins에 다운 받은 플러그인의 압축을 풀어준다. 

3. 이클립스 재시작
이클립스에 고양이가 보이면 플러그인 설치가 된 것이다.

4. 환경변수 설정하기
Window - Preference - Tomcat
해당 버전을 체크하고 이미 설치한 톰캣의 경로를 지정해 준다.
context는 server.xml로 체크
Window - Preference - Tomcat  - Advanced
역시 톰캣의 경로를 지정해 준다.

5. server.xml 변경하기
설치된 톰캣의 설정 파일(conf)을 열어서 server.xml을 open한다.


여기서 docBase의 경로는 이클립스에서 작업하는 프로젝트 파일(이클립스 처음 실행할 때 지정한 경로)의 webapps폴더이며 workDir의 경로는 그 폴더가 들어있는 상위 폴더이다. 포트번호 8080과 80은 이미 설정이 잡혀 있어서 다른 번호로 지정했다. :(

6. 점검하기
localhost:포트번호 를 쳐서 확인한다.



※몇 가지 삽질 비화
1. 포트번호
설치하기 전에 포트번호(8080, 80)를 점검한다. 특히 오라클을 그냥 설치했다면 말이다.
Oracle-OraHome92 => Configuration and Migration Tools => Database Configuration Assistant
오라클 포트 변경하기

2. 경로
맞는지는 모르겠지만 개인적으로 찜찜한 부분. 한글경로는 피하는게 상책이다.

3. 재설치라면
남아있는 폴더, 파일을 확실하게 지워야 한다.


※오라클 웹서버 멈추기

제어판 - 관리도구 - 서비스 - 오라클 HTTPserver - 속성


Posted by zeide
,
* 조금씩, 하지만 자주 발표한다.
* 사이클을 반복해서 돌리면서 개발한다.
* 스펙에 없는 것은 절대 집어넣지 않는다.
* 테스트 코드를 먼저 만든다.
* 야근은 하지마라. 항상 정규 일과 시간에만 작업한다.
* 기회가 생기는 족족 언제 어디서든 코드를 개선한다.
* 모든 테스트를 통과하기 전에는 어떤 것도 발표하지 않는다.
* 조금씩 발표하는 것을 기반으로 하여 현실적인 작업 계획을 마든다.
* 모든 일을 단순하게 처리한다.
* 두 명씩 팀을 편성하고 모든 사람들이 대부분이 코드를 알 수 있도록 돌아가면서 작업한다.

재미난 규칙들.
Posted by zeide
,