大頭RAD
晚上9:05 | Author: Ethan
在 JAVA 的開發世界裡,Eclipse 是無人不知無人不曉的圖形介面開發平台,而接觸過 Eclipse 的人,必定知曉悉歷史,Eclipse 原本是 IBM WebSphere Studio Application Developer(WSAD) 開發軟體的重要的主要核心平台,為使其 WSAD 這個平台能力更加健全和為了推廣自家軟體,在 2001 年,IBM開始運作Eclipse開放原始碼計畫,且投入金錢與人力成立Eclipse聯盟基金會,誘使更多優秀開發者,專心致力於 Eclipse 平台能力的研發,而 IBM 的商業手法不是僅止於此,每當 eclipse 版本的功能穩定時,IBM 就會將其主要核心包回自家的開發軟體。從WSAD一直到現在的 Rational Application Developer(RAD) 7.5,其套裝軟體的核心架構平台就是 Eclipse,下面我們利用 RAD7.5 實作簡單的程式範例,逐步的來虧探一下其能力、特色。

開發環境:
1. Rational Application Developer 7.5 ( 60天試用版 )
下載位址 http://www.ibm.com/developerworks/downloads/r/rad/?S_TACT=105AGX23&S_CMP=DWNL
2. Tomcat Application Server 6.0.20
下載位址 http://tomcat.apache.org/download-60.cgi
3. JDK 6 update 13 或以上
下載位址 http://java.sun.com/javase/downloads/index.jsp

RAD實作環境設定步驟:
1. 設定 RAD 內 Tomcat 6.0.20 伺服器執行的環境 ( 請先將 JDK 6 與 Tomcat 6.0.20 安裝好 )


2. 建立一個動態 Web 專案,並編撰一個簡單的 Servlet 程式與 web.xml,然後執行RAD 內 Tomcat 6.0.20 伺服器,來測試專案執行是否正確

i. 產生一個 Ch1Servlet.java

package org.it100;

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

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

/**
* Servlet implementation class Ch1Servlet
*
* @author Ethan
*/
public class Ch1Servlet extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
PrintWriter out = response.getWriter();
java.util.Date today = new java.util.Date();
out.println("<html>"+"<body>"+"<h1 aligin=center>HF's Chapter1 Servlet</h1>"+"<br>"+ today +"</body>"+"<html>");
}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}


ii. 編寫web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>FHServletCh1</display-name>
<servlet>
<description></description>
<display-name>Ch1Servlet</display-name>
<servlet-name>Ch1Servlet</servlet-name>
<servlet-class>org.it100.Ch1Servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Ch1Servlet</servlet-name>
<url-pattern>/Ch1Servlet.do</url-pattern>
</servlet-mapping>
</web-app>


This entry was posted on 晚上9:05 and is filed under . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.