Tomcat

□DL from
http://tomcat.apache.org/download-55.cgi
choose Windows Service Installer (pgp, md5) to download.
execute.
set environment variable:
variable: CATALINA_HOME
value: C:\Program Files\Apache Software Foundation\Tomcat 5.5
eclipse>file>new>other>server>next>Tomcat v5.5 server>
server host name: localhost
server type: Tomcat v5.5 server
>next>
name:Apach Tomcat v5.5
Tomcat install directory:C:\..\Tomcat5.5
JRE: jdk 1.5.0._x
>finish

□make a project
eclipse>new>other>web>dynamic web project>next>
project name: J2EEPJ
>next>next>
web module sc:
context root: hello
contents directory: WebContent
Java source directory: src
>finish>agree
□make a servlet
project>new>servlet>
Java package: pack
class name: ShowDateServlet
>next>
name: ShowDate
URL mapping: /ShowDate
--ShowDateServlet-----
package pack;

import java.io.IOException;
import java.io.PrintWriter;

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

public class ShowDateServlet extends javax.servlet.http.HttpServlet
implements javax.servlet.Servlet {
private static final long serialVersionUID = 1L;

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

response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("");
out.println("");
out.println(new java.util.Date());
out.println("");
out.println("");
}
}
----------------------
□make a jsp
project>new>jsp
input or select parent folder: J2EEPJ/WebContent
file name: ShowDateJSP
>finish
--ShowDateJSP---------
<'%@ page language="java" contentType="text/html; charset=windows-31j"
pageEncoding="windows-31j" %>
<'!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<'html>
<'head>
<'meta http-equiv="Content-Type" content="text/html; charset=windows-31j">
<'title>ShowDateJSP<'/title>
<'/head>
<'body>

<'%= new java.util.Date() %>

<'/body>
<'/html>
----------------------
□operation check
project>execute>w server>choose a server>
access to
servlet: http://localhost:8080/hello/ShowDate
Jsp: http://localhost:8080/hello/ShowDateJSP.jsp
□war file
placing the war file $CATALINA_HOME\webapps,
the war file would be expanded automatically,
and become ready to execute.
project>export>war file>
web module: J2EEPJ
destination: C:\hello.war


tag : Tomcat

2008-02-10 15:16 : SETUP : コメント : 0 : トラックバック : 0 :
コメントの投稿
非公開コメント

« next  ホーム  prev »

search

ad



counter


tag cloud

category cloud