JSP基础编程

Similar documents
jsp

WWW PHP

基于CDIO一体化理念的课程教学大纲设计

untitled

untitled

EJB-Programming-4-cn.doc

TopTest_Adminstrator.doc

Microsoft PowerPoint - ch6 [相容模式]

2 SGML, XML Document Traditional WYSIWYG Document Content Presentation Content Presentation Structure Structure? XML/SGML 3 2 SGML SGML Standard Gener

weblogic

(CIP) Web /,. :, ISBN X.W T P393.4 CIP (2004) Web ( ) ( / ) : * 787

ebook70-13

1.JasperReport ireport JasperReport ireport JDK JDK JDK JDK ant ant...6

Microsoft Word 样章.dot

D getinitparameternames() 9 下 列 选 项 中, 属 于 Servlet API 中 提 供 的 request 对 象 的 包 装 类 的 是 ( ) A HttpServletRequestWrapper B HttpServletRequest C HttpServ

epub83-1

untitled

09 (File Processes) (mkdir) 9-3 (createnewfile) 9-4 (write) 9-5 (read) 9-6 (deletefile) 9-7 (deletedir) (Exercises)

RunPC2_.doc

(TestFailure) JUnit Framework AssertionFailedError JUnit Composite TestSuite Test TestSuite run() run() JUnit

59 1 CSpace 2 CSpace CSpace URL CSpace 1 CSpace URL 2 Lucene 3 ID 4 ID Web 1. 2 CSpace LireSolr 3 LireSolr 3 Web LireSolr ID

XXXXXXXX

Chn 116 Neh.d.01.nis

ASP 電子商務網頁設計

chapter 2 HTML5 目錄iii HTML HTML HTML HTML HTML canvas

SiteView技术白皮书

epub 61-2


060522達文西密碼_全_.PDF

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

优迈科技教学大纲2009版本

EJB-Programming-3.PDF

Microsoft Word - SCWCD-CH01.doc

Microsoft Word - Final Exam Review Packet.docx

Preface This guide is intended to standardize the use of the WeChat brand and ensure the brand's integrity and consistency. The guide applies to all d

ch_code_infoaccess

Servlet

untitled

WebSphere Studio Application Developer IBM Portal Toolkit... 2/21 1. WebSphere Portal Portal WebSphere Application Server stopserver.bat -configfile..

untitled

Learning Java

Bus Hound 5

UDC The Design and Implementation of a Specialized Search Engine Based on Robot Technology 厦门大学博硕士论文摘要库

What Servlet

前言 C# C# C# C C# C# C# C# C# microservices C# More Effective C# More Effective C# C# C# C# Effective C# 50 C# C# 7 Effective vii

ArcGIS Sever.NET ArcGIS Server Web JAVA ArcGIS Server Web

本章学习目标 小风 Java 实战系列教程 SpringMVC 简介 SpringMVC 的入门案例 SpringMVC 流程分析 配置注解映射器和适配器 注解的使用 使用不同方式的跳转页面 1. SpringMVC 简介 Spring web mvc

运动员治疗用药豁免申报审批办法

1. 2. Flex Adobe 3.

東莞工商總會劉百樂中學

Mechanical Science and Technology for Aerospace Engineering October Vol No. 10 Web SaaS B /S Web2. 0 Web2. 0 TP315 A

國家圖書館典藏電子全文

6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM

RunPCPB8 new feature.PDF

untitled

2/80 2

新・解きながら学ぶJava

Olav Lundström MicroSCADA Pro Marketing & Sales 2005 ABB - 1-1MRS755673

untitled

2 Requirements Documentation Doc Name Doc No. 1.0 Version No. Total Page Generated By V6.0.0 Generated Date 2011/10/21 Checked By Checked Date 2011/10

Logitech Wireless Combo MK45 English

Windows XP

數位圖書館/博物館相關標準 2

RPC SOAP REST API API HTTP JSON XML PHP PHP PHP PHP PHP HTTP request/response cycle HTTP HTTP verbs headers Cookies JSON XML PHP RPC SOAP RESTful HTTP

学 院 人 才 培 养 分 项 自 评 报 告 结 果 汇 总 表 主 要 评 估 指 标 关 键 评 估 要 素 自 评 等 级 1.1 学 校 事 业 发 展 规 划 合 格 1. 领 导 作 用 1.2 办 学 目 标 与 定 位 合 格 1.3 对 人 才 培 养 重 视 程 度 合 格 1

软件测试(TA07)第一学期考试

untitled

Important Notice SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information provided by SUNPLUS TECHNOLO

ebook

ebook4-12

Oracle 4

目录

untitled

大连理工大学专业学位硕士学位论文

RUN_PC連載_8_.doc

台灣地區同學

Microsoft Word _4.doc

Java

Some experiences in working with Madagascar: installa7on & development Tengfei Wang, Peng Zou Tongji university

Untitiled

Microsoft Word - Web Dynpro For ABAP跟踪测试工具简介 _2_.doc

职 位 类 别 : 测 试 工 程 师 工 作 经 验 或 实 习 经 历 : 不 限 岗 位 要 求 : 1. 本 科 及 其 以 上 学 历, 计 算 机 相 关 专 业 2014 届 毕 业 生 ; 2. 实 习 时 间 要 求, 尽 量 一 周 五 个 工 作 日 ; 3. 熟 悉 Wind

untitled

目次 

入學考試網上報名指南

http / /book. sina. com. cn /news /c / /3 /2586. shtml

06-4.indd

BC04 Module_antenna__ doc

A VALIDATION STUDY OF THE ACHIEVEMENT TEST OF TEACHING CHINESE AS THE SECOND LANGUAGE by Chen Wei A Thesis Submitted to the Graduate School and Colleg

● 源起

2. 佔 中 對 香 港 帶 來 以 下 影 響 : 正 面 影 響 - 喚 起 市 民 對 人 權 及 ( 專 制 ) 管 治 的 關 注 和 討 論 o 香 港 市 民 總 不 能 一 味 認 命, 接 受 以 後 受 制 於 中 央, 沒 有 機 會 選 出 心 中 的 理 想 特 首 o 一

Microsoft Word - 苹果脚本跟我学.doc

PowerPoint Presentation

p.2 1 <HTML> 2 3 <HEAD> 4 <TITLE> </TITLE> 5 </HEAD> 6 7 <BODY> 8 <H3><B> </B></H3> 9 <H4><I> </I></H4> 10 </BODY> </HTML> 1. HTML 1. 2.

SEC-220

1 1 大概思路 创建 WebAPI 创建 CrossMainController 并编写 Nuget 安装 microsoft.aspnet.webapi.cors 跨域设置路由 编写 Jquery EasyUI 界面 运行效果 2 创建 WebAPI 创建 WebAPI, 新建 -> 项目 ->

Microsoft Word - WebGoat用户指南-beta2.doc

Microsoft Word - 01.DOC

第1章 簡介

( Version 0.4 ) 1

Transcription:

JSP 基础编程 报告人 : 包亮 邮箱 :rslab@lzb.ac.cn

HTTP 基础 HTTP is a simple, stateless protocol. A client, such as a web browser, makes a request, the web server responds, and the transaction is done.

Client 发出一个请求 : 包括 HTTP 命令和一些附加信息如 C 端用的是什么软件和什么类型的内容. 服务器响应 : 版本号 + 状态码 (200,404) 和服务器的附加信息. 例子 : 见下页

GET /intro.html HTTP/1.0 User-Agent: Mozilla/4.0 (compatible; MSIE 4.0; Windows 95) Accept: image/gif, image/jpeg, text/*, */* HTTP/1.0 200 OK Date: Saturday, 23-May-00 03:25:12 GMT Server: Tomcat Web Server/3.2 MIME-version: 1.0 Content-type: text/html Content-length: 1029 Last-modified: Thursday, 7-May-00 12:15:35 GMT

与服务器交互的方法 把客户端连接服务器并发送的 http 请求叫作方法. 最常见的是 Post 和 Get 方法,POST 是张贴而 GET 是读

Jsp 服务器的搭建 Web 服务器 + 应用程序服务器 + 数据库 Web 服务器 + 独立的 servlet 容器 + 数据库 大多数应用程序服务器和若干独立 servlet 容器都内置了 web 服务.

Apache+tomcat+mysql 安装 j2sdk-1.4.06 安装 apache 安装 tomcat(4.x-5.0.x) apache 和 tomcat 的整合 http://linux.chinaunix.net/doc/netconf/2005-02-02/1058.shtml

一切都是对象 Java 是纯的面向对象程序设计语言.Jsp 继承了 java 的语法和特性. JSP 从这个层次上面可以理解为 : 用 java 的方法来解决 http 协议需求.

Jsp 中的隐含对象 Jsp 的设计开发人员造出了 9 个内置对象, 用于 Http 协议的需求. 内置 : 说明本身 jsp 页面里面就有了. 不需要创建对象. 如 :Request request = new Request();// 不需要.

Hello.jsp 主要向大家展示了 request 内置对象使用方法和页面之间的参数传递. request.getparameter();

Request Response PageContext Session Application Out Config Page Exception

HttpServletRequest request The servlet request. HttpServletResponse response The servlet response. javax.servlet.jsp.jspwriter out The output writer, used like a PrintWriter but it has different buffering characteristics. HttpSession session The user's session. ServletContext application The web application. javax.servlet.jsp.pagecontext pagecontext An object primarily used to abstract the implementation of the server but sometimes used directly to share variables between JSP pages and supporting beans and tags.

幕后的运行机制

经 tomcat 编译过的 hello.jsp 文件 hello.class

JSP 语法 Expressions and Declarations <%! Declaration;[declaration;]+.%> <%=expression%> Saying "Hello" Using a JSP Declaration hello2.jsp 全局变量和局部变量的关系.

Jsp 语法 Directives <%@ directivename attribname= attribvalue %> <%@ page %>

page contenttype Specifies the content type of the generated page. For example: <%@ page contenttype="text/plain" %> The default content type is text/html; charset=8859_1. import Specifies a list of classes and packages the generated servlet should import. Multiple classes can be given in a commaseparated list. For example: <%@ page import="java.io.*,java.util.hashtable" %> The implicit include list is java.lang.*,javax.servlet.*,javax.servlet.http.*,javax.servlet.jsp.*.

buffer Specifies the minimum required size of the response buffer in kilobytes, similar to the servlet method setbuffersize( ). The value should be written as ##kb. A special value of none indicates that content should be passed directly to the underlying PrintWriter in the ServletResponse (which may or may not pass the content directly to the client). For example: <%@ page buffer="12kb" %> The default is 8kb. autoflush Specifies if the buffer should be flushed when it's filled or if instead an IOException should be thrown. A true indicates to flush, a false indicates to throw. For example: <%@ page autoflush="true" %> The default is true. session Indicates the page wants to have access to the user's session. A true puts the session variable in scope and may set a client cookie to manage the session. A false disables access to the session variable. For example: <%@ page session="false" %> The default is true.

errorpage Specifies a page to display if a Throwable is thrown from within the JSP page and is not caught before reaching the server. This proves useful because it's difficult to do try/catch blocks when writing JSP pages. For example: <%@ page errorpage="/error.jsp" %> The default behavior is implementation dependent. The path is context relative, so you don't need to worry about prepending the current context path. The target may be a JSP but doesn't have to be. If the target is a servlet, the servlet may retrieve the Throwable as the request attribute javax.servlet.jsp.jspexception. iserrorpage Indicates the page is intended to be used as the target of an errorpage. If the value is true the page can access an implicit variable named exception to retrieve the Throwable. language Specifies the scripting language used in the code sections of the page. The language used must interact with Java well enough to expose the necessary Java objects to the script environment. For example: <%@ page language="javascript" %> The default is java, the only language blessed by the specification.

JSP 和 JavaBean Javabean 是可重用的类, 使用 <jsp:usebean> 标签可以将 javabeans 直接嵌入到 jsp 页面中或作为一个可供 jsp 调用的操作.

调用 javabean <jsp:usebean id= name scope= page request session application class= classname type= typename > </jsp:usebean>

和 bean 的交互 <jsp:setproperty name= beanname property= * /> <jsp:setproperty name= beanname property= propertyname /> <jsp:setproperty name= beanname propery= propertyname param= paramname />

例 :hello3.jsp 调用了 java 文件, 可以减少 jsp 页面的内容, 把逻辑控制放在 bean 里面,jsp 只起到一个显示作用.

包含和转向 <%@ include file= pathfile %> 其作用范围 :translation time,servlet 创建期 <jsp:include page = pathtodynamicresource flush= true /> 作用范围在请求时间.

<jsp:forward page= pathtodynamicresource /> <jsp:param/>

标签库 让 jsp 页面包含 xml 标签 ( 类似于 html 的标签 ) 最广泛的标签库 apache Taglibs 和 Apache Struts

Jsp 乱码和与数据库连接 Java 用的是 unicode 编码, 本地要依赖于环境系统. Jdbc 数据库联接