实例介绍
Head First Servlet JSP(清晰中文版).PDF
Chapter 1. Why use Servlets JSPS? intro and architecture Everybody wants a web site You have a killer idea for a web site. To destroy the competition, you need a flexible, scalable architecture. You need servlets and sPs. Before we start building. lets take a look at the world wide web from about 40k feet. What we care most about in this chapter are how web clients and web servers talk to one another These next several pages are probably all review for you, espccially if you're already a web application developer, but it'l give us a chance to expose some of the terminology we use throughout the book The web Consists of ga clients (using browsers like Mozilla or i) and server apps like Apache)connected through ires and wireless networks. Our goal is Client 事b to build a web application that clients server Clien around the globe can access. And to become obscenely rich Client Client Client e car you are here p Chapter 1. Why use Servlets JSPs? HeadFirstServletsandJSPByBertBates,KathySierra,BryanBashamISBN:0596005407Publisher:OReillyPreparedforStephenGoss,SafariID:sephengossi@gmx.net Print publication dato: 8/1/2004 Uscr number: 74 7221 Copyright 2006, Safari Books Online, LLC his PDF iS exclusively for your use in accordance with the Safari Terms of Service. No part of it may be reproduced or transmitted in any form by any means wi hout the prior written permission for reprints and excerpts from the publisher Redistribution or other use that violates the fair use priviledge under U.s. copyright laws(see 17 USC107)or that otherwise violates the Safari Terms of Service is strictly prohibited Chapter 1. Why use Servlets JSPS? web server What does your web server do A web server takes a client request and gives something back to the client. A web browser lets a user request a resource. The web servergets the request, finds the resource, and returns something to the user. Sometimes that resource is an HTML page. Sometimes it's a picture. Or a sound file, Or even a pDF document. doesnt matter-the client asks for the thing (resource)and the server sends it back lot where the server is expecting it to be You're of course quite familiar with the 404 Not Found " error-the response you get when the server can t find what it When we say"", we mean either the physical machine(hardware) or the web server application (software). Throughout the book, if the difference between server hardware and software matters. we'll explicitly say which onc(hardwarc or softwarc)we'rc talking about I he client's request contains the name and address(the uRL), of hing the client ng for Web has browser The server usual lots of "content, that 比 d to tent can eb pago JPEGs, ther resource The server's response Contains the tual d it tha rror code i-f Processed) Chapter 1. Why use servlets JSPs? HeadFirstServletsandJSPByBertBates,KathySierra,BryanBashamISBN:0596005407Publisher:OReillyPreparedforStephenGoss,SafariID:sephengossi@gmx.net Print publication dato: 8/1/2004 Uscr number: 74 7221 Copyright 2006, Safari Books Online, LLC his PDF iS exclusively for your use in accordance with the Safari Terms of Service. No part of it may be reproduced or transmitted in any form by any means wi hout the prior written permission for reprints and excerpts from the publisher Redistribution or other use that violates the fair use priviledge under U.s. copyright laws(see 17 USC107)or that otherwise violates the Safari Terms of Service is strictly prohibited Chapter 1. Why use Servlets JSPS? intro and architecture What does a web client do A web client lets the user request something on the server, and shows the user the result of the request. When we talk about clients, though we usually mean both(or either) the hunan user and the browser application The browser is the piece of software(like Netscape or Mozilla) that knows how to communicate with the server. The browscr's other big job interpreting the hTMl code and rendering the web page for the So from now on, when we use the term client, we usually wont care whether we re talking about the human user or the browser app. In other words, the client is the browser app doing wiat the user asked it to do User clicks a link Browser formats the Server finds the n the browser request and sends计t requested page to the serve click User nd renders it into a Server formats the to the client(browser) Browser Server you are here p Chapter 1. Why use Servlets JSPs? HeadFirstServletsandJSPByBertBates,KathySierra,BryanBashamISBN:0596005407Publisher:OReillyPreparedforStephenGoss,SafariID:sephengossi@gmx.net Print publication dato: 8/1/2004 Uscr number: 74 7221 Copyright 2006, Safari Books Online, LLC his PDF iS exclusively for your use in accordance with the Safari Terms of Service. No part of it may be reproduced or transmitted in any form by any means wi hout the prior written permission for reprints and excerpts from the publisher Redistribution or other use that violates the fair use priviledge under U.s. copyright laws(see 17 USC107)or that otherwise violates the Safari Terms of Service is strictly prohibited Chapter 1. Why use Servlets JSPS? Htmlandhttp Clients and servers knowhtmlandhttp A wise question, In order But how do the to communicate, they must HTML clients and servers the web, clients and servers talk to each other? When a server answers a request must speak Http, and browsers must kn。 W HTML sei veI usl lly sends some type of content to so that the browser can display it. Servers often send the browser a set of instructions written in HTML, the Hyper Text Markup Language. The hTmL tells the browser how to present the All weh browsers know what with HTML, although sometines older browser might not understand HTML tells the browser parts of a page that was written using newvervcrsions of HTML how to display the content to the user. Http Most of the conversations held on the eb between clients and servers are Http is the protocol held using the Http protocol which clients and servers use on allows for simple request and respon conversations. The client sends an the web to communicate IITTP request, and the server answers with an htTp response Bottom line if you're a web server you speak Http When a web server sends an html TheserveruseshttpTo page to the client, it sends nd html to the client Http. (you'Ll see the details on how all this works in the next few pages. Fyl: Http stAnds for Hypertext chapter Chapter 1. Why use Servlets JSP HeadFirstServletsandJSPByBertBates,KathySierra,BryanBashamISBN:0596005407Publisher:OReillyPreparedforStephenGoss,SafariID:sephengossi@gmx.net Print publication dato: 8/1/2004 Uscr number: 74 7221 Copyright 2006, Safari Books Online, LLC his PDF iS exclusively for your use in accordance with the Safari Terms of Service. No part of it may be reproduced or transmitted in any form by any means wi hout the prior written permission for reprints and excerpts from the publisher Redistribution or other use that violates the fair use priviledge under U.s. copyright laws(see 17 USC107)or that otherwise violates the Safari Terms of Service is strictly prohibited Chapter 1. Why use Servlets JSPS? intro and architecture Two-Minute HTMl guide When you develop a web page, you use HTML to describe what the page should look like and how it should behave HTML has dozens of tags and hundreds of tag attributes. The goal of TML is to take a text document and add tags that tell the browser how to format thc text Bclow arc the tags wc usc in thc next scvcral recommend the book HTML G XHTML The Defnitive Guid ml, we Tag Description where you put your comments <a> anchor-usually for putting in a hyperlink <align> align the contents left, right, centered, or justified define the boundaries of the documents body a line break (Technically, the <center> and <align>tags have been deprecated in HTML to, but we're <centery center the contents asing them in some of our examples because it's simPler to read than the alternative, and you're here to learn <form> define a form(which usually provides input fields) <h1> the first level heading <head> define the boundaries of the document's heade <html> define the boundaries of the html document Input type> defines an input widget to a form a hew <title> the html document's title you are here p Chapter 1. Why use Servlets JSPs? HeadFirstServletsandJSPByBertBates,KathySierra,BryanBashamISBN:0596005407Publisher:OReillyPreparedforStephenGoss,SafariID:sephengossi@gmx.net Print publication dato: 8/1/2004 Uscr number: 74 7221 Copyright 2006, Safari Books Online, LLC his PDF iS exclusively for your use in accordance with the Safari Terms of Service. No part of it may be reproduced or transmitted in any form by any means wi hout the prior written permission for reprints and excerpts from the publisher Redistribution or other use that violates the fair use priviledge under U.s. copyright laws(see 17 USC107)or that otherwise violates the Safari Terms of Service is strictly prohibited Chapter 1. Why use Servlets JSPS? riting HTML What you write… (the HTML Imagine you're creating a login page. The simple HTml might look something like this: <html> An <I--Some sample HTMI --> <head> <title>A Login Page</title> <body> B <h1 align="center">Skyler's Login Page</h1> The <img> tag is nested ph p align="right"> tag in order to place img src="SKYLER2 jpg"width=130"height=150"/> the image ro ghly where we want it (Remember but The servlet to send alie it bee <form actions'date2 Password: <input type="text"name="param2"/><br/><br/><br/> n We'lltalk The<b>七 <center> later, but brich the browser can collect cause line break <input type=SUBMIT"/> the user's input and return it如othe rver </form> The"submit button the tor </body> </htm1> Relax You need only the most basic HTML knowledg HTML pops up all over the exam. But you're not being tested on your HTML knowledge. You'll see HTML in the context of a large chunk of questions, though, so you need at least some idea of what s happening when you see simple HTML chapter 7 Chapter 1. Why use Servlets JSPs? HeadFirstServletsandJSPByBertBates,KathySierra,BryanBashamISBN:0596005407Publisher:OReillyPreparedforStephenGoss,SafariID:sephengossi@gmx.net Print publication dato: 8/1/2004 Uscr number: 74 7221 Copyright 2006, Safari Books Online, LLC his PDF iS exclusively for your use in accordance with the Safari Terms of Service. No part of it may be reproduced or transmitted in any form by any means wi hout the prior written permission for reprints and excerpts from the publisher Redistribution or other use that violates the fair use priviledge under U.s. copyright laws(see 17 USC107)or that otherwise violates the Safari Terms of Service is strictly prohibited Chapter 1. Why use Servlets& JSPs? intro and architecture What the browser creates The browser reads through the hTMl code, creates the web page, and renders it to the user's display A Login Par http://www.wickedlysmart.com/skylogin.html Apple Mac Amazon eBay Yahoo! News Skyler's Login Page Narre Password you are here p Chapter 1.Why use Servlets &JSPs? ed-first servlets and sP byber_bates kathy sierra frae - basham sen 0596005407-publisher o'Reilly prepared fer sterben gesr safari ip stephengessaemyne PriRt-PublieatioR-Date: 8442004 Ueer-Fumber 747224-Cepyright 2096, Saferi-BeekG-OnlineLL gtheRwHise-violates-the-SafaHi TeHHS-0fServiGe-is-strietly-pfehbilesh Chapter 1. Why use Servlets JSPS? Http protocol What is the httP protocol Http runs on top of Tcp/ ip. If you're not familiar with is rcsponsiblc for making surc that a filc sent from onc network node to another ends up as a complete file at the destination, even though the file is split into chunks whe Key elements of the request the chunks(packets) from one host to another on their way to lcstination,httpthenisanothcrnetwork be Http method( the action to protocol that has Web-specific features, but it depends TCP/IP to get the complete re The page to access(a URL) fromoneplacetoanotherThestructureofanhttp Form nversation is a simple request/Response sequen arguments to a method) browser requests, and a server responds Httpr Http respo Client elements e strea )Status code for whether The content(the actual HTML, imag Relax yOu dont have to memorize the HTtP spec ThehttpprotocolisanIeTfstandardRfg2616.Ifyoucare (Fortunately, the exam doesnt expect you to. Apache is an example of a Web server that processes HttpreqUestS. Mozilla is an example of a Wcb browser that providcs the uscr with the mcans to makc Http requests and to view the documents returned by the server 10 Chapter 1. Why use Servlets JSPs? HeadFirstServletsandJSPByBertBates,KathySierra,BryanBashamISBN:0596005407Publisher:OReillyPreparedforStephenGoss,SafariID:sephengossi@gmx.net Print publication dato: 8/1/2004 Uscr number: 74 7221 Copyright 2006, Safari Books Online, LLC his PDF iS exclusively for your use in accordance with the Safari Terms of Service. No part of it may be reproduced or transmitted in any form by any means wi hout the prior written permission for reprints and excerpts from the publisher Redistribution or other use that violates the fair use priviledge under U.s. copyright laws(see 17 USC107)or that otherwise violates the Safari Terms of Service is strictly prohibited 【实例截图】
【核心代码】
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论