sitelink1  
sitelink2  
sitelink3  

1. 테스트를 위한 HelloWorldServlet.java와 TestXdoclet.java 파일을 만든다.

2. HelloWorldServlet.java (web.xml 자동생성을 테스트하기 위한 소스)

package net.javajigi.chapter3.servlet;

import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**

* web.xml을 생성할 때 쓸 주석문

*

* @web.servlet name="HelloWorldServlet"
*     display-name="HelloWorld Servlet"
*
* @web.servlet-init-param  name="name"
*        value="${hello.servlet.name}"
*
* @web.servlet-mapping url-pattern="/HelloWorld/*"
* @web.servlet-mapping url-pattern="*.HelloWorld"
* @web.servlet-mapping url-pattern="/HelloWorldServlet"
*/

public class HelloWorldServlet extends HttpServlet {

protected void doGet(
 HttpServletRequest request,
 HttpServletResponse response)
 throws ServletException, IOException {
 process(request, response);
}

protected void doPost(
 HttpServletRequest request,
 HttpServletResponse response)
 throws ServletException, IOException {
 process(request, response);
}

protected void process(
 HttpServletRequest request,
 HttpServletResponse response)
 throws ServletException, IOException {
 ServletConfig config = this.getServletConfig();
 String name = config.getInitParameter("name");

 response.setContentType("text/html");
 java.io.PrintWriter out = response.getWriter();
 out.println("<html>");
 out.println("<head>");
 out.println("<title>HelloWorld Servlet</title>");
 out.println("</head>");
 out.println("<body>");
 out.println("<h1>Hi!! " + name + ". Hello World!!</h1>");
 out.println("</body>");
 out.println("</html>");
 out.close();
}
}

3. TestXdoclet.java (struts-config.xml 생성테스트를 위한 소스)

package com.test;

import javax.servlet.http.*;

import org.apache.struts.action.*;
import org.apache.struts.actions.*;

/**
* struts-config.xml이 생성시킬 때 쓰이는 주석문

* @struts.action
*      name="signonForm"
*      path="/login"
*      input="/vm/login/Login.vm"
*      scope="request"
*      validate="false"
*
* @struts.action-forward
*      name="success"
*      path="/preferences.screen"
*
* @struts.action-forward
*      name="login"
*      path="/vm/login/Login.vm"
*
*/

public class Testxdoc extends DispatchAction{

public ActionForward search(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception{
 
 return mapping.findForward("success");
}

}

4. Ant는 기본적으로 Eclipse에 포함되어 있으니 xdoclet만 설치하면 된다.

   xdoclet는 아래의 url에서 다운 받으면 된다.

   http://sourceforge.net/project/showfiles.php?group_id=31602

   압축을 푼 후 애플리케이션의 lib폴더에 모든 .jar파일을 import(이클립스의 import기능)하거나 복사한다. 또 Tomcat의 common/lib/servlet-api.jar 파일도 복사해 준다.

5. 프로젝트에서 build.xml 파일을 생성한다. 이 파일이 생성되면 Eclipse에서는 자동으로 Ant Editer를 작동한다.(필자의 경우에는 생성 후 바로 열리는 문서는 Ant Editer가 적용되지 않아 파일을 한번 닫고 다시 열어보니 적용이 되었다.)

6. build.xml을 작성한다.

<?xml version="1.0" encoding="UTF-8"?>
<project name="TestXdoclet" default="all">
<property file="build.properties"/>

<target name="init" description="initialize the properties">
 <mkdir dir="${javadoc.dir}"/>
 <path id="struts.class.path">
  <fileset dir="${lib.dir}" includes="**/*.jar"/>
 </path>
 
 <path id="xdoclet.class.path">
  <fileset dir="${lib.dir}" includes="**/*.jar"/>
 </path>
</target>

<target name="generateDD" depends="init">

 <taskdef name="webdoclet"
  classname="xdoclet.modules.web.WebDocletTask"
  classpathref="xdoclet.class.path"
 />  

  <webdoclet
   destdir="${build.dir}"
   mergedir="${resource.dir}/merge">
   
   <fileset dir="${src.dir}">
    <include name="**/*.java"/>
   </fileset>
   
   <deploymentdescriptor servletspec="2.3" destdir="${build.webinf.dir}">
   </deploymentdescriptor>
 
   <strutsconfigxml
    version="1.1"
    destdir="${build.webinf.dir}">
   </strutsconfigxml>
  </webdoclet>    
</target>
     
<target name="all">
 <!--<antcall target="clean"/>-->
 <antcall target="generateDD" />
</target>
</project>

7. build.properties를 작성한다.

src.dir=${basedir}/src
web.dir=${basedir}/pages

javadoc.dir=${basedir}/docs

build.dir=${basedir}/WebContent


build.webinf.dir=${build.dir}/WEB-INF/
build.lib.dir=${build.webinf.dir}/lib
build.class.dir=${basedir}/build
build.src.dir=${build.webinf.dir}/src
build.sql.dir=${build.dir}/sql

lib.dir=${basedir}/WebContent/WEB-INF/lib
resource.dir=${build.webinf.dir}

dist.dir=${basedir}/dist

deploy.dir=cbcyber
war.name=cbcyber.war

sql.name=sql-export.sql

backup.dir=d:/work/backup/

.properties에 나열된 경로는 자신의 애플리케이션 구조에 맞게 알맞게 수정한다.

8. 프로젝트 익스플로러에서 컨텍스트 메뉴(마우스 오른버튼)를 호출한 후 RUN as 에서 Ant build로 실행한다.

9. 위와 같은 과정이 정상적으로 실행된다면 web.xml파일과 struts-config.xml파일이 자동으로 생성 되어 있을 것이다.

번호 제목 글쓴이 날짜 조회 수
28 Gradle 을 Groovy 에서 Kotlin으로 마이그레이션 file 황제낙엽 2023.11.16 62
27 [2014~2015] gradle 영문 튜토리얼 (Getting Started With Gradle) 황제낙엽 2023.07.13 748
26 [Intellij, Spring Boot, Lombok, Gradle] 프로젝트에 lombok 추가 file 황제낙엽 2023.07.12 65
25 Maven 프로젝트를 Gradle로 변경하기 file 황제낙엽 2023.07.12 68
24 Maven, Gradle 의 비교와 Gradle + Eclipse에서 gradle의 빌드가 안될때 황제낙엽 2023.07.11 109
23 Jenkins 백업 (Thinbackup) file 황제낙엽 2021.07.22 153
22 Jenkins Restful API로 Job 과 Build 정보 조회 황제낙엽 2020.09.02 145
21 Jenkins+TFS 연동 예제 황제낙엽 2020.09.01 143
20 [Jenkins] Java Sample with Jenkins Restful API 황제낙엽 2020.08.12 203
19 Jenkins의 Restful API file 황제낙엽 2020.08.11 140
18 jenkins에서 tfs에 접속하여 브랜치와 변경집합으로 소스를 다운로드하는 예제 황제낙엽 2020.08.11 141
17 (Jenkins) Application Server의 Continuous Integration 구성의 필요성 file 황제낙엽 2020.05.20 97
16 Nexus Repository 황제낙엽 2020.05.20 72
15 Jenkins Rest API 사용기 file 황제낙엽 2020.03.26 946
14 Ant 로 Java Application 실행시 Target 에 파라미터를 입력하여 Arguments 로 전달하여 실행시키기 file 황제낙엽 2012.06.05 2277
13 ANT에서 Classpath 설정시 순서 주의 황제낙엽 2010.07.10 460
12 Ant에서 "${java.class.path}"이 의미하는바 황제낙엽 2010.07.10 121
11 ANT 를 이용한 RMI 컴파일 ( rmic 로 stub 생성하기 ) 황제낙엽 2010.05.26 115
10 [Maven] 로컬 레파지터리에 사용자 jar 추가하기 file 황제낙엽 2010.04.20 285
9 Maven 툴을 이용한 효율적인 프로젝트 관리 방안 황제낙엽 2007.01.30 213