第六章 JavaEE Web开发技术

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

JavaEEWebWebApplicationTech.ofJavaEENukopen!PDF-XChange!PDF-XChangeWebWebServletJSPJSFTagMVCWebNukopen!PDF-XChange!PDF-XChangeWhat’stheWeb?TheWorldWideWeb()isaninformationspaceinwhichtheitemsofinterest,referredtoasresources,areidentifiedbyglobalidentifierscalledUniformResourceIdentifiers(URI).---ReferencedfromW3CWeb–HTML(HyperTextMarkupLanguage)&XML(eXtendedMarkupLanguage)Web–HTTP/HTTPS(HyperTextTransferProtocol)Web–URI(UniformResourceIndentification)WebNukopen!PDF-XChange!PDF-XChangeWhat’stheWeb?HTTP/HTTPSNukopen!PDF-XChange!PDF-XChangeHTTP/HTTPS–Request/ResponseHTTPClient/ServerCommunicationRequest=(||)CRLF[]=URLHTTP=GET|HEAD|POST|URL=++HTTPPOSTResponse=(||)CRLF[]=HTTPNukopen!PDF-XChange!PDF-XChangeWhat’saWebApplication?Awebapplicationisadynamicextensionofaweborapplicationserver.–Presentation-oriented:Apresentation-orientedwebapplicationgeneratesinteractivewebpagescontainingvarioustypesofmarkuplanguage(HTML,XML,andsoon)anddynamiccontentinresponsetorequests.–Service-oriented:Aservice-orientedwebapplicationimplementstheendpointofawebservice.Presentation-orientedapplicationsareoftenclientsofservice-orientedwebapplications.Nukopen!PDF-XChange!PDF-XChangeTheclientsendsanHTTPrequesttothewebserver.AwebserverthatimplementsJavaServletandJavaServerPagestechnologyconvertstherequestintoanHTTPServletRequestobject.Thisobjectisdeliveredtoawebcomponent,whichcaninteractwithJavaBeanscomponentsoradatabasetogeneratedynamiccontent.ThewebcomponentcanthengenerateanHTTPServletResponseoritcanpasstherequesttoanotherwebcomponent.EventuallyawebcomponentgeneratesaHTTPServletResponseobject.ThewebserverconvertsthisobjecttoanHTTPresponseandreturnsittotheclient.Nukopen!PDF-XChange!PDF-XChangeJavaEEWeb–JavaServlet–JavaServerPages–JavaServerFaces–JavaTagsNukopen!PDF-XChange!PDF-XChangeServletServletHttpServletdoGet()doPost()HttpResponseHttpSessionNukopen!PDF-XChange!PDF-XChangeWhat’saServlet?AservletisaJavaprogramminglanguageclassthatisusedtoextendthecapabilitiesofserversthathostapplicationsaccessviaarequest-responseprogrammingmodel.Nukopen!PDF-XChange!PDF-XChangeServletNukopen!PDF-XChange!PDF-XChange*;importjavax.servlet.*;importjavax.servlet.http.*;publicclassHelloWorldextendsHttpServlet{publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{PrintWriterout=response.getWriter();out.println(HelloWorld);}}Nukopen!PDF-XChange!PDF-XChangeHttpServletServlet–init()servlet–destroy()javaservlet–doGet()HTTPGET–doPost()HTTPPOST–getServletInfo()servletNukopen!PDF-XChange!PDF-XChange()()doPostdoPost()()Nukopen!PDF-XChange!PDF-XChange()()doPostdoPost()()–get–post–requestHttpServletRequestservletHttp–responseHttpServletResponseservlet,HttpprotectedvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,java.io.IOExceptionprotect

1 / 79
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功