2014년 7월 22일 화요일

tomcat hello jar sample in eclipse.

Eclipse ant setting jdk
eclipse > Preference > Ant > Runtime > Global Entries
add External JARs -> jdk 6.0_45 tools.jar add


Project Setting 

web.xml

<web-app version="2.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xsi:schemalocation="http:/java.sun.com/dtd/web-app_2_3.dtd">
  <servlet>
    <servlet-name>hello</servlet-name>
    <servlet-class>test.HelloServlet</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>hello</servlet-name>
    <url-pattern>/hello</url-pattern>
  </servlet-mapping>
</web-app>


build.xml

<?xml version="1.0" encoding="UTF-8"?>
<project name="myWeb" default="build-jar" basedir=".">

<property name="tomcat-home" value="E:/dev/was/apache-tomcat-7.0.54" />
<property name="project-name" value="test" />

<path id="jar-project-classpath">
<fileset dir="lib" includes="*.jar" />
<fileset dir="${tomcat-home}/bin" includes="*.jar" />
<fileset dir="${tomcat-home}/lib" includes="*.jar" />
</path>

<target name="clean">
<delete dir="bin" />
<mkdir dir="bin" />
</target>

<target name="copy-non-java-files">
<copy todir="bin" includeemptydirs="false">
<fileset dir="src" excludes="**/*.java" />
</copy>
</target>

<target name="compile-jar-classes" depends="clean,copy-non-java-files">
<javac srcdir="src" destdir="bin" classpathref="jar-project-classpath" />
</target>
<target name="clean-jar">
<delete dir="build" />
<mkdir dir="build" />
</target>

<target name="jar">
<jar basedir="bin" destfile="build/${project-name}.jar">
<manifest>
<attribute name="Built-By" value="${builder}" />
<attribute name="Built-On" value="${build-info.current-date}" />
<attribute name="Built-At" value="${build-info.current-time}" />
</manifest>
</jar>
</target>
<target name="build-jar">
<antcall target="compile-jar-classes" />
<antcall target="clean-jar" />
<antcall target="jar" />
</target>

</project>

test.HelloServlet.java

package test;

import java.io.*;

import javax.servlet.http.*;
import javax.servlet.*;

public class HelloServlet extends HttpServlet {
  public void doGet (HttpServletRequest req,
                     HttpServletResponse res)
    throws ServletException, IOException
  {
    PrintWriter out = res.getWriter();

    out.println("Hello, world!");
    out.close();
  }
}

댓글 없음:

댓글 쓰기

eclipse rcp dialog resize

  Dialog 안에 메소드를 만든다. private void autoResize(){     getShell().layout( true, true);     final Point newSize = getShell().computeSize...