Upload
preston-blanchard
View
84
Download
4
Embed Size (px)
DESCRIPTION
第一讲 J2EE 基础. 博和利初级培训 — 开发技能. 技术路线与开源产品. 技术路线 J2EE Development without EJB 开源产品 Tomcat, JBoss, MySQL, Struts, Spring, Hibernate, Acegi, ValueList, JXL, Pentaho, JasperReport, iReport, JFreeChart, JBPM ……. 企业级应用架构. Acegi. Struts. JSP/JSTL/Taglib. PDF/Excel. FreeMarker/ Velocity. - PowerPoint PPT Presentation
Citation preview
第一讲 第一讲 J2EEJ2EE 基础基础
博和利初级培训博和利初级培训 —开发技能 —开发技能
技术路线与开源产品
•技术路线– J2EE Development without EJB
•开源产品– Tomcat, JBoss, MySQL, Struts, Spring, Hibernate, Acegi, ValueList, JXL, Pentaho, JasperReport, iReport, JFreeChart, JBPM ……
企业级应用架构
Struts JSP/JSTL/Taglib PDF/ExcelFreeMarker/Velocity
Spring
Hibernate JDBC
Acegi
SQL Server MySQL Oracle
Tomcat / JBoss
JVM
Windows Linux Max OS X Unix
Struts + Spring + Hibernate
Business Layer
Spring
DAO Classes
UI Layer
Struts - MVC
Struts Action,ActionForm, JSP,struts-config.xml,
etc
Service Locator
Persistence Layer
Hibernate
Transactions
Hibernate SessionManagement
Business ServiceClasses
DataSource,Connection Pool
Query LanguageSupport and otherHibernate services
Domain Model Business Objects
Http 协议的简单介绍
•HTTP , Hyper Text Transfer Protocol 超文本 传输协议•浏览器将客户端请求( Request )形成符合 HTTP协议
的流传递给服务器。•服务器根据客户浏览器的请求进行处理,将结果
形 成符合 HTTP协议的流,返回给客户端,形成响应( Response )
•请求 -响应形成了 HTTP协议的基本通信方式•这些形成的流通常是文本流
一个典型的 <form>
•<form method="post" name="loginForm" action=“/login“>
• 用户名:
• <input name="username"><br>
• 密 码:
• <input name="password" type="password">
• <br>
• <input type="submit" value=" 提交 ">
•</form>
浏览器与服务器交互
Request
Response
一个典型的 Http 请求
POST http://download.microtool.de/login HTTP/1.1
Host: download.microtool.de
Accept:*/*
Pragma: no-cache
Cache-Control: no-cache
Referer: http://download.microtool.de/
User-Agent:Mozilla/4.04[en](Win95;I;Nav)
Username=yuannan&password=111111
HTTP 请求剖析
POST http://download.microtool.de/login HTTP/1.1
通过 POST 方法获得指定 URL 下的文件。除了 POST 方法以外,还有 GET , DEL , HEAD 等等
HTTP 请求剖析
•Host: download.microtool.de
•Host :指定请求资源的 Intenet 主机和端口号,必须表示请求 url 的原始服务器或网关的位置。HTTP/1.1 请求必须包含主机头域,否则系统会以400 状态码返回。
HTTP 请求剖析
username=yuannan&password=111111
POST 到服务器中的数据。
HTTP 请求剖析
•User-Agent: Mozilla/4.04[en](Win95;I;Nav)
•User-Agent 头域的内容包含发出请求的用户信息。
典型的 HTTP 响应
HTTP/1.0 200 OK Date: Mon,31 Dec 2001 04:25:57 GMT Server: Apache/1.3.14(Unix) Content-type: text/html Last-modified: Tue,17 Apr 2001 06:46:28 GMT Etag: "a030f020ac7c01:1e9f" Content-length: 39725426
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>……
HTTP 响应剖析
•HTTP/1.0 200 OK
•协议版本号,状态号
HTTP 响应剖析
•Server: Apache/1.3.14(Unix)
•服务器的名称,版本,以及服务器所在的操作系统名称
HTTP 响应剖析
•Content-type: text/html
•相应的内容的类型, html 文本。
HTTP 响应剖析
•Last-modified: Tue,17 Apr 2001 06:46:28 GMT
Etag: "a030f020ac7c01:1e9f "
•Last-modified 文件的最后修改时间,而 Etag 则是以及文件内容的生成的一个字符序列。通常用于实现客户端缓存,降低服务器压力。当客户端发现请求并没有被修改的话则直接使用本地的缓存。
HTTP 响应剖析
•Content-length: 39725426
•响应内容的长度,单位为 Byte 。
HTTP 响应剖析
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dt
d">
<html>
<head>……
浏览器解析的 html 文本
观察 HTTP 协议的两个工具
•HttpWatch, IE 插件
•Ethereal, 抓包工具
Apache HTTP Server 简介
•The Apache HTTP Server Project is an effort to develop
and maintain an open-source HTTP server for modern
operating systems including UNIX and Windows NT. The
goal of this project is to provide a secure, efficient and
extensible server that provides HTTP services in sync with
the current HTTP standards .
Servlet 简介
•Java Servlet technology provides Web developers with a
simple, consistent mechanism for extending the functionality
of a Web server and for accessing existing business system
s. A servlet can almost be thought of as an applet that runs
on the server side--without a face. Java servlets make man
y Web applications possible.
•Current version 2.5
•doPost , doGet
JavaServer Pages 简介
•JavaServer Pages (JSP) technology provides a simpli
fied, fast way to create dynamic web content. JSP techn
ology enables rapid development of web-based applicati
ons that are server- and platform-independent.
Tomcat Servlet/JSP Container 简介
•Apache Tomcat is the servlet container that is used in
the official Reference Implementation for the
Java Servlet and JavaServer Pages technologies. The J
ava Servlet and JavaServer Pages specifications are dev
eloped by Sun under the Java Community Process.
•Scriptlet , JSTL
浏览器与服务器交互
POST /login HTTP/1.1Accept: image/gif, image/x-xbitmap, application/msword, */*Referier: http://www.yahaogroup.com/Accept-Language: zh-cn
username=yuannan&password=123 ……
文本流
Request
Response
Tomcat
Servlet
文本流
HTTP/1.1 200 OKDate: Mon, 20 Aug 2007 05:48:34 GMTContent-Length: 1100Content-Type: text/html;charset=UTF-8Server: Microsoft-IIS/6.0X-Powered-By: ASP.NET<HEAD><TITLE> 成功 </TITLE> ……
浏览器与服务器交互(详细)
POST …… username=yuannan&password=123 ……
文本流
TomcatRequest
username
password
yuannan
123
ParameterMap
key value
Host Server
Response
Servlet
doPost(Request, Response){ //业务处理 // 结果输出 … …}
浏览器与服务器交互(详细)
•HTTP/1.1 200 OK
•Date: Mon, 20 Aug 2007 05:48:34 GMT
•Content-Length: 1100
•Content-Type: text/html;charset=UTF-8
•Server: Microsoft-IIS/6.0
•X-Powered-By: ASP.NET
•<HEAD>
•<TITLE> 成功 </TITLE> ……
文本流
作业
•下载 J2SE 6 及其文档•下载 Java EE 5 API
•下载 Tomcat 6 及其文档•下载 Struts1.2.9 及其文档•下载 Spring 2.5.6 及其文档•下载 Hibernate3.2 及其文档•下载 Eclipse3.2 •下载 JSTL1.1 API
作业
•下载 HttpWatch , Ethereal 并观察 Http 协议•复习今天所讲授的内容
FAQ
谢谢!