1 / 11

JSP 簡介

JSP 簡介. Outline. 什麼是 JSP? JSP 運作模式 安裝 JSP JSP 範例一 JSP 範例二. 什麼是 JSP?. Java Server Pages 用來開發 “ 含動態內容網頁 ” 的技術. JSP 運作模式. JSP File. Request. Resource. Response. HTMP File. HTMP File. 安裝 JSP. 需安裝 j2sdk-1_4_0_03-windows-i586.exe http://java.sun.com/j2se/1.4/download.html

kyrene
Download Presentation

JSP 簡介

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JSP 簡介

  2. Outline • 什麼是JSP? • JSP運作模式 • 安裝JSP • JSP範例一 • JSP範例二

  3. 什麼是JSP? • Java Server Pages • 用來開發 “含動態內容網頁”的技術

  4. JSP運作模式 JSP File Request Resource Response HTMP File HTMP File

  5. 安裝JSP 需安裝 j2sdk-1_4_0_03-windows-i586.exe http://java.sun.com/j2se/1.4/download.html jakarta-tomcat-4.1.18.exe http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/

  6. 安裝JSP • 設定環境: • WINDOW98: • 改c:\config.sys,加入以下設定 • SHELL=C:\COMMAND.COM /E:4096 /P • 改c:\autoexec.bat,加入以下設定 • SET PATH=C:\JDK\BIN;%PATH% • SET JAVA_HOME=C:\JDK • SET CATALINA_HOME=C:\TOMCAT • SET CLASSPATH=C:\JDK\lib\ • WINDOW2000及XP: • 開始→設定→控制台→系統→進階→環境變數 • 編輯系統變數PATH,加上C:\JDK\BIN。 • 新增變數CLASSPATH,值輸入C:\JDK\LIB。

  7. 參照網址 • Java 1.4 API • http://java.sun.com/j2se/1.4.1/docs/api/

  8. JSP範例一 • <%@ page contentType="text/html;charset=big5"%> • <%@ page import="java.util.Date" %> • <html> • <head> • <meta http-equiv="Content-Type" content="text/html; charset=big5"> • <title>Test1</title> • </head> • <body> • <% • Date Clock = new Date(); • out.println(“現在是 ”+Clock.getHours()+“點鐘!"); • %> • </body> • </html>

  9. JSP範例二 • 輸入密碼 密碼錯誤 Test2a Test2b 程式 送出Request 密碼判斷 輸入密碼 Test2b Html 密碼正確

  10. JSP範例二(Test2a) • <%@ page contentType="text/html;charset=big5"%> • <%@ page import="java.io.*" %> • <HTML> • <HEAD> • <TITLE>test2a</TITLE> • <META content="text/html; charset=big5" http-equiv=Content-Type> • </HEAD> • <BODY> • <center> • <form name="form1" method="post" action="Test2b.jsp"> • <input type="password" name="passwdofMT" size="16" maxlength="16"> • <input type="submit" name="b1" value="確定"> • </form> • </center> • </BODY> • </HTML>

  11. <%@ page contentType="text/html;charset=big5"%> <%@ page import="java.io.*" %> <% String passwd=request.getParameter("passwdofMT"); boolean LogOk=false; if (passwd.equals("1234")) LogOk=true; if (LogOk==false) { response.sendRedirect(response.encodeRedirectURL("Test2a.jsp")); } else { %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=big5"> <title>Test2b</title> </head> <body> <center> <font size=4 color="#0000FF"><b>你進來了!!</b></font><br> </center> </body> </html> <% } %> Test2b

More Related