Servlet

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

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

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

资源描述

3Sept.2008©NeusoftConfidentialCopyright2008ByNeusoftGroup.AllrightsreservedJAVAWEB——ServletIT3Sept.2008ConfidentialServlet3Sept.2008Confidential•••Servlet•Servlet•Servlet3Sept.2008©NeusoftConfidential3.13.1.1Http3Sept.2008ConfidentialHTTPHTTP3Sept.2008Confidential•–MethodURIHTTPVersionGET/index.htmlHTTP/1.1•/()–––•–•–HTTP3Sept.2008Confidential•HttpServletRequest–getMethod():String–getRequestURI():String–getProtocol():String–getHeader(Stringname):String–getHeaderNames():Enumeration–getRemoteAddr():String–getRemoteHost():String–getInputStream():InputStream–setCharacterEncoding(Stringencoding)3Sept.2008©NeusoftConfidential3.13.1.2Http3Sept.2008ConfidentialHTTPHTTP3Sept.2008ConfidentialHTTP•HTTP–()•HTTPVersionStatusCodeMessageHTTP/1.0200OK–/()•••–•–•3Sept.2008ConfidentialHTTP•1•2•3•4•53Sept.2008ConfidentialHTTPServiceUnavailable503NotImplemented501InternalServerError500UnsupportedMediaType415MethodNotAllowed405NotFound404Unauthorized401BadRequest400HTTP3Sept.2008ConfidentialServletHttp•HttpServletResponse–ServeltResponse•–setContentTypeStringtype)–setHeaderStringheadNameStringvalue)–addHeader(StringheadNameStringvalue)–getWriterPrintWriter–getOutputStreamOutputStream3Sept.2008Confidential•HTTPHTTPJavaHTTP•–HTTPHTTP–JavaWeb–WebHTTP–ServletURI–HTTP3Sept.2008©NeusoftConfidential3.23Sept.2008Confidential•––HTTP–3Sept.2008Confidential•HTTP––•HttpServletRequest–getParameter(StringparameterName):String–getParameterValues(Stringname):String[]–getParameterNames():EnumerationHTTP3Sept.2008Confidential•Formformmethod=postaction=“/webdemo/loginServletinputtype=“text”name=“userName”/inputtype=passwordname=password/inputtype=submitname=actionvalue=OK//form3Sept.2008Confidential•Form–ACTIONURL–METHODHTTP•Input–TYPEGUIcomponent–NAME–VALUEForm3Sept.2008Confidential•HTML–Textfield–Submitbutton–Resetbutton–Checkbox–Radiobutton–Password–Hidden–Selectdrop-downlist–Textarea•HTML3Sept.2008Confidential•–Hello•–form–formaction––•ServletURI3Sept.2008ConfidentialHTTP•–•fieldName1=fieldValue1&fieldName2=fieldValue2&...–•GethttpURI•Posthttp3Sept.2008ConfidentialGetPost•Get/Post–HTTP–•post3Sept.2008©NeusoftConfidential3.3Servlet3Sept.2008ConfidentialServlet3Sept.2008Confidential•–Servlet•–init(ServletConfig)–destroy()–service(ServletRequestreq,ServletResponseres)•–ServletRequest–ServletResponseServlet3Sept.2008ConfidentialServlet——3Sept.2008Confidential•–Servlet–ServletConfig•–init(ServletConfigconfig)•ServletConfiginit–destroy()–abstractservice(…)9init()GenericServlet3Sept.2008Confidential•–init()–destroy()9service(HttpServletRequestreq,HttpServletResponseres)9doXxx•doGet(…)•doPost(…)•doDelete(…)•HTTP–HttpServletRequest–HttpServletResponseHttpServlet3Sept.2008ConfidentialWebHttp•WebGET–HttpServlet.service(ServletRequestrequest,ServletResponseresponse)–HttpServlet.service(HttpServletRequestrequest,HttpServletResponseresponse)–MyServlet.doGet(HttpServletRequestrequest,HttpServletResponseresponse)3Sept.2008ConfidentialHttpServlet3Sept.2008ConfidentialHTTP3Sept.2008ConfidentialHTTP3Sept.2008ConfidentialHTTP3Sept.2008©NeusoftConfidential3.43Sept.2008Confidential•–WebServlet3Sept.2008ConfidentialServlet•ServletWebServlet3Sept.2008ConfidentialServlet•–Servlet3Sept.2008ConfidentialServletSTM•Servlet3Sept.2008Confidential•ServletSTM–SingleThreadModelSTM3Sept.2008ConfidentialHttpServlet•Servlet•Servlet•DDWebServlet3Sept.2008Confidential•Web•ServletWebServlet–Servlet3Sept.2008Confidential•STM•Servlet•3Sept.2008©NeusoftConfidential3.5Servlet3Sept.2008ConfidentialWebServletservletservlet-nameInitServlet/servlet-nameservlet-classdevoid.course.user.web.InitServlet/servlet-classload-on-startup0/load-on-startup!--web0--/servlet3Sept.2008ConfidentialServletservletservlet-nameInitServlet/servlet-nameservlet-classdevoid.course.user.web.InitServlet/servlet-classinit-paramparam-namemyConfigFile/param-nameparam-valuemy-config.xml/param-value/init-param/servlet3Sept.2008ConfidentialServlet•GenericServlet–getInitParameter(StringparamName):String3Sept.2008ConfidentialCopyright©2008

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

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

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

×
保存成功