a) 從www.java.sun.com下載JDK(JAVA開發套件),並安裝,現假設為c:\jdk1.3 b) 組建JSP運行環境:要使JSP運行起來首先要建造JSP運行環境。現在我們常用到的應用程式伺服器軟體主要有WebLogic Application Server,Apache Tomcat,Allarie Jrun。WebLogic是現在市場上佔有率最高的一種伺服器軟體,功能強大,配置也很簡單,作為商業應用的伺服器是很好的選擇,不過作為初學應用,建議還是不要的好,因為這是商業軟體需要購買。
vii. 建立一個Bean執行個體並設定其屬性:"";class屬性:從一個class中樣本一個對象;id屬性:指示此class對象的引用名;scope屬性: Bean存在的範圍以及id變數名的有效範圍,如果為page則只在此頁面類有效(下次調用該頁面時時將重新建立class對象);如為session則在session有效期間類,此class對象只建立一次;如為Application則class在整個程式運行工程中始終有效,並且只建立一次(相當於靜態量)
d) Tomcat的JSP常式介紹:
< !-- Copyright (c)
1999 The Apache Software
Foundation. All rights
reserved.
Number Guess Game
Written by Jason Hunter
< jasonh@kasoftware.com>,
CTO, K&A Software
http://www.servlets.com -->;
< %@ page import = "num.NumberGuessBean" %>
< ! -匯入的Java包- >
< jsp:useBean id="numguess"
class="num.NumberGuessBean"
scope="session"/ >
< ! -建立對象並設定其應用程式名稱為numguess
並申明此對象在session有效期間內始終有效-->
< html>
< head>
< title>Number Guess< /title>
< /head>
< body bgcolor="white">
< font size=4>
< % if (numguess.getSuccess())
{
%>
//調用NumberGuessBean對象的getSuccess方法
Congratulations!
You got it.
And after just
< %= numguess.getNumGuesses()%>
tries.< p>
< % numguess.reset(); %>
Care to < a href="numguess.jsp">try again?
< % } else if (numguess.getNumGuesses() == 0)
{
%> Welcome to the Number Guess game.
I'm thinking of a number between 1 and 100.
< form method=get>
What's your guess?
< input type=text name=guess>
< input type=submit value="Submit">
< /form>
< % } else { %>//
Good guess, but nope. Try < b>
< %= numguess.getHint() %>< /b>.
You have made < %= numguess.getNumGuesses()
%> guesses.< p>
I'm thinking of a number between 1 and 100.
< form method=get> What's your guess?
< input type=text name=guess>
< input type=submit value="Submit">
< /form> < % } %>
< /font>
< /body>
< /html>