기본 콘텐츠로 건너뛰기

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();
  }
}

댓글

이 블로그의 인기 게시물

윈도우 톰캣 네트워크 드라이버 잡기

윈도우 톰캣 네트워크 드라이버 설정(windows tomcat network driver setting) TOMCAT_HOME/conf/server.xml 의 Host 노드 아래 경로 추가     <Context path="/resources" docBase="//192.168.200.100/cifs/pds" /> 서버스 재구동 하면 다음 메시지 뜸 SEVERE [localhost-startStop-1] org.apache.catalina.startup.ContextConfig.beforeStart Exception fixing docBase for context [/resources] java.io.IOException: 사용자 이름 또는 암호가 올바르지 않습니다 at java.io.WinNTFileSystem.canonicalize0(Native Method) at java.io.WinNTFileSystem.canonicalize(WinNTFileSystem.java:428) at java.io.File.getCanonicalPath(File.java:618) at org.apache.catalina.startup.ContextConfig.fixDocBase(ContextConfig.java:593) at org.apache.catalina.startup.ContextConfig.beforeStart(ContextConfig.java:744) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:300) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94) at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:401)...

quartz 사용 하기

http://www.quartz-scheduler.org/documentation/quartz-2.2.x/quick-start.html 프로젝트 만들고 , lib 안에 다운로드 받은 jar 들 복사 후 QuartzTest.java 생성 1. 샘플 ================================================ QuartzTest.java ================================================ import org.quartz.Scheduler; import org.quartz.SchedulerException; import org.quartz.impl.StdSchedulerFactory; import static org.quartz.JobBuilder.*; import static org.quartz.TriggerBuilder.*; import static org.quartz.SimpleScheduleBuilder.*; public class QuartzTest { public static void main(String[] args) { try { // Grab the Scheduler instance from the Factory Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler(); // and start it off scheduler.start(); scheduler.shutdown(); } catch (SchedulerException se) { se.printStackTrace(); } } } ======================================================= log4j.properties 생성 ===================================================...

tomcat https 설정 및 http to http redirect

보통은 할일이 없는데 이걸 내가 할 줄이야.. I. 서버 인증서 설치 해서 크롬이나 ie에서 보안경고 안보이게. II. 톰캣 : 80  ==> 443 리다이렉트 I. 서버 인증서 설치 해서 크롬이나 ie에서 보안경고 안보이게. 1. 인증서 생성 1.1. 자바 스탠다드 키스토어 포맷으로 생성 ( java standard key store : jks ) 설치될 서버 도메인 확정 test.mydomain.com => 생성할 도메인으로 바꾸시면 됩니다. "%JAVA_HOME% \b in \k eytool" -genkey -alias myssl -keypass 인증서비밀번호 \ -storepass 인증서비밀번호 -keyalg RSA -sigalg SHA1withRSA \ -dname "CN=test.mydomain.com, OU=OrgUnit, O=AssetPlus, C=KR" \ -keystore %USERPROFILE%\test.mydomain.com.jks 이때 CN=test.mydomain.com 정확히 적으셔야 인증이 마무리 됩니다. 1.2. 인증서 요청파일 CSR(Certificate Signing Reuest) 파일 생성 "%JAVA_HOME% \b in \k eytool" -certreq -keyalg RSA -alias myssl \ -sigalg SHA1withRSA -keystore %USERPROFILE%\ test .mydomain.com.jks \ -file %USERPROFILE%\test.mydomain.com.certreq.csr CSR 파일을 열어보면  이렇게 생겨 있습니다.  이제 무료 인증 싸이트 가입 해서 인증을 요청 합니다. 와우사인 업체입니다. https://buy.wosign.com/free/#ssl Request a F...