Java語言程序設計10E LiangPPT習題案例38slide.ppt

(55頁)

'Java語言程序設計10E LiangPPT習題案例38slide.ppt'
*Chapter 38 JavaServer Page*ObjectivesTo create a simple JSP page (§38.2).To explain how a JSP page is processed (§38.3).To use JSP constructs to code JSP script (§38.4).To use predefined variables and directives in JSP (§§38.5-38.6).To use JavaBeans components in JSP (§38.7-38.9).To develop database applications using JSP (§38.7-38.9).To forward requests from a JSP page to another (§38.10).*A Simple JSPCurrentTimeCurrent time is Run*How Is a JSP Processed?*JSP ConstructsThere are three types of scripting constructs you can use to insert Java code into the resultant servlet. They are expressions, scriptlets, and declarations.expressionscriptletdeclaration A JSP expression is used to insert a Java expression directly into the output. It has the following form: The expression is evaluated, converted into astring, and sent to the output stream of the servlet.*JSP ConstructsThere are three types of scripting constructs you can use to insert Java code into the resultant servlet. They are expressions, scriptlets, and declarations.expressionscriptletdeclaration A JSP scriptlet enables you to insert a Java statement into the servlet’s jspService method, which is invoked by the service method. A JSP scriptlet has the following form: *JSP ConstructsThere are three types of scripting constructs you can use to insert Java code into the resultant servlet. They are expressions, scriptlets, and declarations.expressionscriptletdeclaration A JSP declaration is for declaring methods or fields into the servlet. It has the following form: *JSP CommentHTML comments have the following form: If you don’t want the comment appear in the resultant HTML file, use the following comment in JSP:*Listing 38.1 Computing FactorialsFactorial <% for (int i = 0; i Factorial of is   JSP scriptletJSP expressionJSP declarationRun*JSP Predefined VariablesYou can use variables in JSP. For convenience, JSP provides eight predefined variables from the servlet environment that can be used with JSP expressions and scriptlets. These variables are also known as JSP implicit objects.requestresponseoutsessionapplicationconfigpagecontextpage Represents the client’s request, which is an instance of HttpServletRequest. You can use it to access request parameters, HTTP headers such as cookies, hostname, etc.*JSP Predefined VariablesYou can use variables in JSP. For convenience, JSP provides eight predefined variables from the servlet environment that ca。省略部分。torial">Factorial of isGettingAssociating the bean properties with the input parameters. Getting number*package chatper40; public class FactorialBean { private int number;  /** Return number property */ public int getNumber() { return number; }  /** Set number property */ public void setNumber(int newValue) { number = newValue; }  /** Obtain factorial */ public long getFactorial() { long factorial = 1; for (int i = 1; i <= number; i++) factorial *= i; return factorial; }}Getting*DESIGN GUIDE Mixing a lot of Java code with HTML in a JSP page makes the code difficult to read and to maintain. You should move the Java code to a .java file as much as you can.* FactorialBean Compute Factorial Using a Bean Enter new value: Factorial of is GettingNewFactorialBean * Display Time Choose locale and time zone Current time is GettingTimeBean *Forwarding Requests from JavaServer Pages Web applications developed using JSP generally consist of many pages linked together. JSP provides a forwarding tag in the following syntax that can be used to forward a page to another page.*Example: Browsing Database TablesThis example creates a JSP database application that browses tables. When you start the application, the first page prompts the user to enter the JDBC driver, URL, username, and password for a database. After you login to the database, you can select a table to browse. Upon clicking the Browse Table Content button, the table content is displayed. Run
關 鍵 詞:
liangppt 習題 10 10e 案例 38slide 程序設計 語言 38 java
 天天文庫所有資源均是用戶自行上傳分享,僅供網友學習交流,未經上傳用戶書面授權,請勿作他用。
關于本文
本文標題:Java語言程序設計10E LiangPPT習題案例38slide.ppt
鏈接地址: http://www.476824.live/p-51617557.html
關于我們 - 網站聲明 - 網站地圖 - 資源地圖 - 友情鏈接 - 網站客服點擊這里,給天天文庫發消息,QQ:1290478887 - 聯系我們

本站為“文檔C2C交易模式”,即用戶上傳的文檔直接賣給(下載)用戶,本站只是中間服務平臺,本站所有文檔下載所得的收益歸上傳人(含作者)所有【成交的100%(原創)】。本站是網絡服務平臺方,若您的權利被侵害,侵權客服QQ:1290478887 歡迎舉報。

[email protected] 2017-2027 http://www.476824.live 網站版權所有

粵ICP備19057495號 

收起
展開
球探网即时蓝球比分 河南十一选五基本走势图 湖北十一选五爱彩乐,电脑版 黑龙江快乐十分分布图 十大老品牌网赌大全 浙江20选5最新 基金逢低加仓的技巧 山西快乐十分开奖结果双 股融贷配资 江西快3官网 哪个平台炒股好