chap1 introductionPPT幻灯片.ppt_第1页
chap1 introductionPPT幻灯片.ppt_第2页
chap1 introductionPPT幻灯片.ppt_第3页
chap1 introductionPPT幻灯片.ppt_第4页
chap1 introductionPPT幻灯片.ppt_第5页
已阅读5页,还剩47页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、,Practice Course (II),The Development of Java Web Programming,1,Course Information,Instructor: 刘洪娟:liuhj Office: 综合楼303 Telephone: 83680831 Courseware: See later on Blackboard.,2,Textbook Originally for intelligent consumer- electronic devices; Then used for creating web pages with dynamic content;

2、Now also used for: Large-scale enterprise applications development WWW server functionality enhancement Applications for consumer devices (cell phones, etc.),7,1.2 Java Web Programming,Keywords in Job Postings,8,1.2 Java Web Programming,Java2 Platform J2SE (Java 2 Standard Edition): desktop applicat

3、ion J2ME (Java 2 Micro Edition): embedded/mobile application J2EE (Java 2 Enterprise Edition): distributed web application,J2SE Kernel class of Java e.g. database connection, Interface definition, Input and output,9,1.2 Java Web Programming,J2EE and .NET in Web Programming,Languages in .NET platform

4、 C#, based on C and C+ Visual Basic C+,10,1.2 Java Web Programming,Kernel technology of J2EE HTML/XML (eXtensible Markup Language) Servlet/JSP (Java Server Pages) JavaBean EJB(Enterprise JavaBean) JDBC(Java Database Connectivity) JMS(Java Message Service) JTS/JTA(Java Transaction Service /Architectu

5、re) ,11,1.3 MVC framework,Two JSP patterns Model1:JSP+Javabean, JSP serves as view and controller. 1. JSP page responses the request of client; 2. JavaBean deals with business rules; 3. JavaBean interacts with database; 4. JSP page display the results.,12,1.3 MVC framework,Two JSP patterns Model2:JS

6、P+Javabean+Servlet, Servlet serves as controller, also called MVC 1. Servlet accept the request of client; 2. Servlet invoke different JavaBeans; 3. JavaBean interacts with database; 4. Servlet transfer the results to JSP; 5. JSP page display the results.,13,1.3 MVC framework,MVC framework Model: re

7、presents data and business rules that govern access and updates of this data. View: renders the content of a model and maintains consistency in its presentation when the model changes. Controller: accepts the request of users, invokes models to perform the actions and responds by selecting an approp

8、riate view.,14,1.3 MVC framework,MVC framework,The relation among view, controller and model,15,1.3 MVC framework,Running process of MVC,HTML Javascript JSP,Servlet,EJB/JavaBean (Plain old Java object),16,1.3 MVC framework,Objective of MVC framework To separate core business model functionality from

9、 the presentation and control logic; Re-use of model components: to allow multiple views to share the same enterprise data model; Low coupling: the change of one tier can not affect other tiers; It is convenient to divide the work. Disadvantages Expend more time to separate the three tiers Manage mo

10、re files Adapt to large application,17,1.3 MVC framework,Common MVC components Struts: the most popular MVC component WebWork: a J2EE web framework Struts 2: combination of structs and WebWork Spring MVC: combine the advantages of Spring JSF(Java Server Faces):integrated in JEE5.0 Tapestry: a web ap

11、plication framework .net MVC,18,1.3 MVC framework,Struts Apache Struts is an open-source web application framework for developing Java EE web applications. The architecture of Struts,19,1.3 MVC framework,Struts Struts-config.xml Controller(ActionServlet): get a request, encapsulate the request into

12、a ActionForm, and dispatch it to corresponding Action class; Action access JavaBean. View: Struts provide many JSP tag library. Model: three types of bean: ActionForm, Action and JavaBean. The request uses *.do to provide, which direct to ActionServlet.,20,1.4 Development Tools,Development kit JDK(J

13、ava Development Kit) Platform Eclipse: open source, not only an IDE(Integrated Development Environment), but also a PDE(Plug-in Development Environment) Plugin MyEclipse(9.0) J2EE integrated development environment Integrate JDK1.6, Tomcat and Eclipse3.6.1 Coding, debugging, testing and deploying,21

14、,1.4 Development Tools,Web Server Tomcat(7.0) Open source, web application server The engine to run Servlet and JSP Other server: JBoss, Oracle, Resin, Weblogic and Websphere Database management system MySQL(5.0) An open source DBMS and a popular choice of database for use in web applications,22,1.4

15、 Development Tools,Install JDK Notice: installing path without blanks Environment Variable My computer-Properties-advanced- environment variables classpath = .;C:jdk1.6libtools.jar; C:jdk1.6libdt.jar path = C:jdk1.6bin Test the JDK,23,1.4 Development Tools,Install Tomcat Right JRE is needed when Tom

16、cat is installed. The default port is 8080. Update the port installing pathconfserver.xml,24,1.4 Development Tools,Install MyEclipse Relate Tomcat and MyEclipse:Window -References-MyEclipse-Application Servers-Tomcat-Tomcat 7.x,25,1.4 Development Tools,Test the development environment File-new-Web p

17、roject- project name (Test) Expand the project- right click WebRoot -new-JSP-JSP name(Hello.jsp) Insert some JSP codes, ,26,1.4 Development Tools,Test the development environment Deploy the project: click “deploy” button, click “add” button and deploy the project “Test” to server Tomcat.,27,1.4 Deve

18、lopment Tools,Test the development environment Start up Tomcat server,28,1.4 Development Tools,Test the development environment Input http:/localhost:8080/Test/Hello.jsp into address bar in IE,29,1.5 Web client and server,A web server takes a client request and gives something back to the client The

19、 server means either the physical machine or the application on web server. When the server can not find the resource, the response is “404 not find” error. A web client lets the user request something on the server, and shows the result of the request to the user. The browser is the piece of softwa

20、re. The browsers big job is interpreting the HTML code and rendering the web page for the user.,30,1.5 Web client and server,What does your web server do?,The clients request contains the name and address(the URL), of the thing the client is looking for.,The server usually has lots of “content” that

21、 it can send to clients. That content can be web pages, JPEGs and other resources.,The servers response contains the actual document that the client requested(or an error code if the request could not be processed).,31,1.5 Web client and server,Clients and servers know HTML and HTTP HTML tells the b

22、rowser how to display the content to the user. HTTP is the protocol clients and servers use on the web to communicate. HTTP runs on top of TCP/IP. The server uses HTTP to send HTML to the client.,32,1.5 Web client and server,Two-minute HTML guide When you develop a web page, you use HTML to describe

23、 what the page should look like and how it should behave. HTML has dozens of tags and hundreds of tag attributes. The goal of HTML is to take a text document and add tags that tell the browser how to format the text.,33,1.5 Web client and server, A simple HTML example name: pass: ,34,1.5 Web client

24、and server,The structure of a HTTP conversation is a simple Request/Response sequence: a browser request and a server respond.,Key element of the request stream: HTTP method(the action to be performed) The page to access(a URL) Form parameters(like arguments to a method),Key element of the response

25、stream: A status code(for whether the request was successful) Content-type(text, picture, HTML, etc.) The content(the actual HTML, image, etc.),35,1.5 Web client and server,HTTP method: GET and POST GET is a simple HTTP method and the point of GET is to get something back from the server. The total

26、number of characters in a GET is really limit(depending on the sever). The data you send with the GET is appended to the URL in the browser bar, so whatever you send is exposed.,?user=lhj&pass=me,36,1.5 Web client and server,A HTTP GET request,The path to the resource on the web server,The parameter

27、s are included on the “request”,37,1.5 Web client and server,HTTP method: GET and POST POST is a more powerful request. With POST, you can request something and at the same time send form data to the server. To make complex requests on the server. For instance, the application might want all of a lo

28、ng forms data to be added to a database.,38,1.5 Web client and server,A HTTP POST request,The message body, sometimes called “payload”,The parameters are down here in the body, so the data arent limited and need not be put in the request line.,39,1.5 Web client and server,HTTP 1.0 and HTTP 1.1 HTTP

29、1.1 provides persistent connection HTTP 1.0 protocol HTTP 1.1 protocol,40,1.5 Web client and server,URL(Uniform Resource Locators),http:/localhost:8080/Test/Hello.jsp,Protocol,Server: The unique name of the server youre looking for. This name maps to a unique IP address.,Port: A server application i

30、s identified by a port. The default port is 80.,Path: The path to the resource being requested on the server.,Resource: The name of the content being requested.,41,1.5 Web client and server,The whole process of client request and server response,42,1.6 Why use Servlets and JSPs,Web servers love serv

31、ing static web pages A static page just sits there in a directory. These pages go straight to the client just exactly as they were put on the server. Every client sees the same thing.,But what if I want the current time to show up on my page?,What if I want a page that has something dynamic?,43,1.6

32、Why use Servlets and JSPs,Why build web pages dynamically? The Web page is based on data submitted by the user E.g., results page from search engines and order confirmation pages at on-line stores The Web page is derived from data that changes frequently E.g., a weather report or news headlines page

33、,44,1.6 Why use Servlets and JSPs,Why build web pages dynamically? The Web page uses information from databases or other server-side sources. E.g., an e-commerce site could use a servlet to build a Web page that lists the current price and availability of each item that is for sale.,45,1.6 Why use Servlets and JSPs,Two things the web server alone cant do 1 Dynamic content Just-in-time pages dont exist before the request comes in. The request comes in, the helper app “writes” the HTML and the web server

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论