首先出現的是安裝向導歡迎界面,直接點擊“next”繼續,選擇安裝類型,選擇“自定義”custom安裝,然后點“next”下一步,出現自定義安裝界面,選擇安裝路徑:c:/mysql server 4.1(可自定義)點“ok”返回到自定義安裝界面,路徑已改為設置的路徑,點“next”,準備開始安裝,點“install”開始安裝,完成后出現創建mysql.com帳號的界面。
“install as windows service”一定要勾選,這是將mysql作為windows的服務運行。“service name”就用默認的“mysql”下面的“launch the mysql server automatically”一定要勾選,這樣windows啟動時,mysql就會自動啟動服務,要不然就要手工啟動mysql。
<?xml version="1.0" encoding="iso-8859-1"?> <!doctype web-app public "-//sun microsystems,inc.//dtd web application 2.3//en" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>my web application</display-name> <description> a application for test. </description> </web-app>
在myapp下用記事本新建一個測試的jsp頁面,文件名為index.jsp,文件內容如下:
<html><body><center> now time is: <%=new java.util.date()%> </center></body></html>
重啟tomcat
打開瀏覽器,輸入http://localhost:8080/myapp/index.jsp
看到當前時間的話說明成功安裝。
建立自己的servlet:
用記事本新建一個servlet程序,文件名為helloworld.java,文件內容如下:
import java.io.*;import javax.servlet.*;import javax.servlet.http.*;public class helloworld extends httpservlet{public void doget(httpservletrequest request,httpservletresponse response)throws servletexception,ioexception{response.setcontenttype("text/html"); printwriter out = response.getwriter();out.println("<html><head><title>");out.println("this is my first servlet");out.println("</title></head><body>");out.println("<h1>hello,world!</h1>");out.println("</body></html>");}}
package test; public class testbean{ private string name = null; public testbean(string strname_p){ this.name=strname_p; } public void setname(string strname_p){ this.name=strname_p; } public string getname(){ return this.name; } }
<%@ page import="test.testbean" %> <html><body><center> <% testbean testbean=new testbean("this is a test java bean."); %> java bean name is:<%=testbean.getname()%> </center></body></html>
重啟tomcat,啟動瀏覽器,輸入http://localhost:8080/myapp/testbean.jsp 如果看到輸出java bean name is: this is a test java bean 就說明編寫的javabean成功了。