1. Trang chủ
  2. » Công Nghệ Thông Tin

Head First Servlets and JSP phần 5 ppt

74 356 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 74
Dung lượng 2,18 MB

Nội dung

XVLQJ-63 \RXDUHKHUH  &RGH0DJQHWV $QVZHUV LPSRUW VHVVLRQ RXW LPSRUWMDYDXWLO # ^! ` KWPO!ERG\! $UUD\/LVW UHTXHVW SDJH $UUD\/LVW VHVVLRQ JHW3DUDPHWHU´QDPHVµ JHW$WWULEXWH³QDPHV´ ZKLOH JHW$WWULEXWH´KREE\µ DO UHTXHVW !  LWKDV1H[W LPSRUW ´MDYDXWLO´ JHW3DUDPHWHU³KREE\´ ,I\RXUDQVZHUORRNVDOLWWOHGLIIHUHQWEXW\RX VWLOOWKLQNLWVKRXOGZRUN³WU\LW<RX·OOKDYHWR PDNHWKHVHUYOHWWKDWWDNHVWKHIRUPUHTXHVW VHWVDQDWWULEXWHDQGIRUZDUGVGLVSDWFKHV WKHUHTXHVWWRWKH-63  !   7KHIULHQGVZKRVKDUH\RXUKREE\RI DUHEU! UHTXHVW LWQH[W ! ,WHUDWRULW DOLWHUDWRU ! EU! ERG\!KWPO!   !  # Start a scriptlet up here and end it here. Use an expression. Finish the while loop block! (If you forget this, it wonÕt compile). `! We need the import page directive because of ArrayList and Iterator. Chapter 7. Being a JSP Chapter 7. Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 0596005407 Publisher: O'Reilly Prepared for Augusto Jaramillo Forcada, Safari ID: augustojf.cv@gmail.com Print Publication Date: 8/1/2004 User number: 729515 Copyright 2007, Safari Books Online, LLC. This 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 without 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.  FKDSWHU R R-ATHRANDOM Rhv R-ATHRANDOM R3TRINGShFOOv RNEW3TRING;= R R RFALSE RNEW#OUNTER 9DOLG" All primitive literals are Þne. NO! The semicolon canÕt be here. String literal is Þne. Yes, the method returns a double. NO! You canÕt have a variable declaration here. Yes, because the new String array is an object, and ANY object can be sent to a println() statement. NO! The arithmetic is Þne, but thereÕs a space between the % and the =. It canÕt be <% =, it must be <%= . Sure, this resolves to a boolean, so it prints ÔtrueÕ. We already said primitive literals are Þne. No problem. This is just like the String[] it prints the result of the objectÕs toString() method. 6KDUSHQ \RXU SHQFLO $16:(56 9DOLGDQG,QYDOLG([SUHVVLRQV YDOLGDQGLQYDOLGH[SUHVVLRQV )KWUUMV\ 9ESYOUCANPUTCOMMENTSINYOUR *30)FYOUREA*AVAPROGRAMMERWITH VERYLITTLE(4-,EXPERIENCEYOU MIGHTlNDYOURSELFTYPING THISISACOMMENT WITHOUTTHINKINGTWICE"UTIFYOU DOTHENUNLESSITSWITHINASCRIPTLET ORDECLARATIONTAGYOULLENDUP $)30,!9).'THATTOTHECLIENTASPART OFTHERESPONSE)NOTHERWORDSTOTHE #ONTAINERTHOSETWOSLASHESAREJUST MORETEMPLATETEXTLIKEh(ELLOvOR h%MAILISv 9OUCANPUTTWODIFFERENTTYPESOF COMMENTSINA*30   +70/FRPPHQW!  7KH&RQWDLQHUMXVWSDVVHVWKLVVWUDLJKWRQ WRWKHFOLHQWZKHUHWKHEURZVHULQWHUSUHWV LWDVDFRPPHQW   -63FRPPHQW!  7KHVHDUHIRUWKHSDJHGHYHORSHUVDQG MXVWOLNH-DYDFRPPHQWVLQD-DYDVRXUFH ILOHWKH\·UHVWULSSHGRXWRIWKHWUDQVODWHG SDJH,I\RX·UHW\SLQJD-63DQGZDQWWR SXWLQFRPPHQWVDERXWZKDW\RX·UHGRLQJ WKHZD\\RX·GXVHFRPPHQWVLQD-DYD VRXUFHILOHXVHD-63FRPPHQW ,I\RXZDQWFRPPHQWVWRVWD\DVSDUW RIWKH+70/UHVSRQVHWRWKHFOLHQW DOWKRXJKWKHEURZVHUZLOOKLGHWKHPIURP WKHFOLHQW·VYLHZXVHDQ+70/FRPPHQW  Chapter 7. Being a JSP Chapter 7. Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 0596005407 Publisher: O'Reilly Prepared for Augusto Jaramillo Forcada, Safari ID: augustojf.cv@gmail.com Print Publication Date: 8/1/2004 User number: 729515 Copyright 2007, Safari Books Online, LLC. This 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 without 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. XVLQJ-63 \RXDUHKHUH  )81NWZ\PMOMVMZI\ML[MZ^TM\ 4HE#ONTAINERGENERATESACLASSFROMYOUR*30THAT IMPLEMENTSTHE(TTP*SP0AGEINTERFACE4HISISTHEONLY PARTOFTHEGENERATEDSERVLETS!0)THATYOUNEEDTO KNOW9OUDONTCARETHATIN4OMCATFOREXAMPLEYOUR GENERATEDSERVLETEXTENDS RUJDSDFKHMDVSHUUXQWLPH+WWS-VS%DVH !LLYOUNEEDTOKNOWABOUTARETHETHREEKEYMETHODS MVS,QLW MVS'HVWUR\ LQWHUIDFH!! MDYD[VHUYOHWMVS-VS3DJH BMVS6HUYLFH+WWS6HUYOHW5HTXHVW+WWS6HUYOHW5HVSRQVH LQWHUIDFH!! MDYD[VHUYOHWMVS+WWS-VS3DJH   MVS,QLW 7KLVPHWKRGLVFDOOHGIURPWKHLQLWPHWKRG <RXFDQRYHUULGHWKLVPHWKRG&DQ\RXILJXUHRXWKRZ"   MVS'HVWUR\ 7KLVPHWKRGLVFDOOHGIURPWKHVHUYOHW·VGHVWUR\PHWKRG <RXFDQRYHUULGHWKLVPHWKRGDVZHOO   BMVS6HUYLFH 7KLVPHWKRGLVFDOOHGIURPWKHVHUYOHW·VVHUYLFHPHWKRG ZKLFKPHDQVLWUXQVLQDVHSDUDWHWKUHDGIRUHDFKUHTXHVW 7KH&RQWDLQHUSDVVHVWKH5HTXHVWDQG5HVSRQVHREMHFWVWR WKLVPHWKRG  <RXFDQ·WRYHUULGHWKLVPHWKRG<RXFDQ·WGR$1<7+,1*ZLWK WKLVPHWKRG\RXUVHOIH[FHSWZULWHFRGHWKDWJRHVLQVLGHLW DQGLW·VXSWRWKH&RQWDLQHUYHQGRUWRWDNH\RXU-63FRGH DQGIDVKLRQWKHBMVS6HUYLFHPHWKRGWKDWXVHVLW You can override these. You CANNOT override this!  ,W¶V127LQIURQWRIWKHRWKHUWZRPHWKRGV MVS,QLWDQGMVS'HVWUR\7KLQNRILWWKLV ZD\WKHXQGHUVFRUHLQIURQWRIWKHPHWKRG PHDQV³GRQ¶WWRXFK´ 6RQRXQGHUVFRUHLQIURQWRIWKHQDPH PHDQV\RXFDQRYHUULGH%XWLIWKHUH,6 DQXQGHUVFRUHLQIURQWRIWKHPHWKRG QDPH\RXPXVW127WU\WRRYHUULGHLW 1RWHWKHXQGHUVFRUH DWWKHIURQWRIWKH B MVS6HUYLFHPHWKRG Chapter 7. Being a JSP Chapter 7. Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 0596005407 Publisher: O'Reilly Prepared for Augusto Jaramillo Forcada, Safari ID: augustojf.cv@gmail.com Print Publication Date: 8/1/2004 User number: 729515 Copyright 2007, Safari Books Online, LLC. This 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 without 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.  FKDSWHU 4QNMKaKTMWNI2;8 9OUWRITETHEJSPlLE 4HE#ONTAINERWRITESTHEJAVAlLEFORTHESERVLETYOUR*30BECOMES :HE&RQWDLQHU .LPZULWHVDMVSÀOH DQGGHSOR\VLWDV SDUWRIDZHEDSS  7KH&RQWDLQHU´UHDGVµWKHZHE[PO''IRU WKLVDSSEXWGRHVQ·WGRDQ\WKLQJHOVHZLWKWKH MVSÀOHXQWLOWKHÀUVWWLPHLW·VUHTXHVWHG "[POYHU VLRQ ´´ HQFRGLQJ ´87)´"! '2&7<3( ZHE[PO :HE&RQWDLQHU 7KHFOLHQWKLWVDOLQN WKDWDVNVIRUWKHMVS  7KH&RQWDLQHUWULHVWR75$16/$7(WKHMVS LQWRMDYDVRXUFHFRGHIRUDVHUYOHWFODVV      0\-63BMVSFODVV SDFNDJHRUJ DSDFKH LPSRUW MD YD[VHUYOHW +WWS6HUY OHW 0\-63BMVSMDYD KWPO! ERG\! LQW[! +HOOR  [! ERG\! KWPO! 0\-63MVS WUDQVODWH UHTXHVW JHQHUDWH :HE&RQWDLQHU  7KH&RQWDLQHUWULHVWR&203,/(WKH VHUYOHWMDYDVRXUFHLQWRDFODVVÀOH FRPSLOH JHQHUDWH JSP syntax errors are caught in this phase. Java language/syntax errors are caught here. -63OLIHF\FOH KWPO! ERG\! LQW[! +HOOR  [! ERG\! KWPO! 0\-63MVS ItÕs just sitting here on the server waiting for a client to request it. SDFNDJHRUJ DSDFKH LPSRUW MD YD[VHUYOHW +WWS6HUY OHW 0\-63BMVSMDYD Chapter 7. Being a JSP Chapter 7. Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 0596005407 Publisher: O'Reilly Prepared for Augusto Jaramillo Forcada, Safari ID: augustojf.cv@gmail.com Print Publication Date: 8/1/2004 User number: 729515 Copyright 2007, Safari Books Online, LLC. This 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 without 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. XVLQJ-63 \RXDUHKHUH  :HE&RQWDLQHU  7KH&RQWDLQHU/2$'6WKH QHZO\JHQHUDWHGVHUYOHWFODVV :HE&RQWDLQHU  7KH&RQWDLQHULQVWDQWLDWHVWKH VHUYOHWDQGFDXVHVWKHVHUYOHW·V MVS,QLWPHWKRGWRUXQ MVS,QLW  7KH&RQWDLQHUFUHDWHVDQHZWKUHDGWR KDQGOHWKLVFOLHQW·VUHTXHVWDQGWKH VHUYOHW·VBMVS6HUYLFHPHWKRGUXQV :HE&RQWDLQHU      0\-63BMVSFODVV ORDG 0\-63B MVS 0 \ - 6 3 B M V S EHFRPHV 7KHREMHFWLVQRZDIXOOÁHGJHGVHUYOHW UHDG\WRDFFHSWFOLHQWUHTXHVWV 0\-63B MVS BMVS6HUYLFH (YHU\WKLQJWKDWKDSSHQVDIWHU WKLVLVMXVWSODLQROGVHUYOHW UHTXHVWKDQGOLQJ (YHQWXDOO\WKHVHUYOHWVHQGVD UHVSRQVHEDFNWRWKHFOLHQWRU IRUZDUGVWKHUHTXHVWWRDQRWKHU ZHEDSSFRPSRQHQW 2;8TQNMKaKTMKWV\QV]ML Chapter 7. Being a JSP Chapter 7. Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 0596005407 Publisher: O'Reilly Prepared for Augusto Jaramillo Forcada, Safari ID: augustojf.cv@gmail.com Print Publication Date: 8/1/2004 User number: 729515 Copyright 2007, Safari Books Online, LLC. This 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 without 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.  FKDSWHU <ZIV[TI\QWVIVLKWUXQTI\QWV PIXXMV[WVTa76+- 7HENYOUDEPLOYAWEBAPPWITHA*30THE WHOLETRANSLATIONANDCOMPILATIONSTEPHAPPENS ONLYONCEINTHE*30SLIFE/NCEITSBEEN TRANSLATEDANDCOMPILEDITSJUSTLIKEANYOTHER SERVLET!NDJUSTLIKEANYOTHERSERVLETONCETHAT SERVLETHASBEENLOADEDANDINITIALIZEDTHEONLY THINGTHATHAPPENSATREQUESTTIMEISCREATIONOR ALLOCATIONOFATHREADFORTHESERVICEMETHOD3O THEPICTUREONTHEPREVIOUSTWOPAGESISFORONLY THElRSTREQUEST :RZ,DPWUXO\LPSUHVVHG, ZRXOGQHYHUKDYHJXHVVHGWKDW WKH\FRXOGPDNHUHTXHVWLQJD-63 WDNHMXVWDVPXFKRYHUKHDGDVFDOOLQJD PHWKRGRQDQ(-%,·PWKLQNLQJWKHFOLHQW KDVWRZDLWZKDW ÀYHPLQXWHV IRUDOO WKDWWUDQVODWLQJFRPSLOLQJDQG LQLWLDOL]LQJ" 4  /+SOTHATMEANSONLYTHElRSTCLIENTTOASK FORTHE*30TAKESTHEBIGHIT"UTTHERE-534BEA WAYTOCONlGURETHESERVERTOPRETRANSLATEAND COMPILERIGHT $  !LTHOUGHITSONLYTHEFIRSTCLIENTTHATHASTO WAITMOST#ONTAINERVENDORS$/GIVEYOUAWAYTOASK FORTHEWHOLETRANSLATIONCOMPILATIONTHINGTOHAPPEN INADVANCESOTHATEVENTHEFIRSTREQUESTHAPPENSLIKE ANYOTHERSERVLETREQUEST "UTWATCHOUTITSVENDORDEPENDENTANDNOT GUARANTEED4HERE)3AMENTIONINTHE*30SPEC*30 OFASUGGESTEDPROTOCOLFOR*30PRECOMPILATION 9OUMAKEAREQUESTFORTHE*30APPENDINGAQUERY STRINGhJSP?PRECOMPILEvANDTHE#ONTAINERMIGHTIF ITCHOOSESDOTHETRANSLATIONCOMPILATIONRIGHTTHEN INSTEADOFWAITINGFORTHEFIRSTREALREQUEST WUDQVODWLRQDQG FRPSLODWLRQ Chapter 7. Being a JSP Chapter 7. Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 0596005407 Publisher: O'Reilly Prepared for Augusto Jaramillo Forcada, Safari ID: augustojf.cv@gmail.com Print Publication Date: 8/1/2004 User number: 729515 Copyright 2007, Safari Books Online, LLC. This 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 without 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. XVLQJ-63 \RXDUHKHUH  ,IWKH-63WXUQVLQWRD VHUYOHW,ZRQGHULI,FDQ FRQÀJXUHVHUYOHWLQLWSDUDPHWHUV DQGZKLOH,·PDWLW,ZRQGHULI,FDQ RYHUULGHWKHVHUYOHW·VLQLWPHWKRG 6KDUSHQ \RXU SHQFLO 7KLQNDERXWWKHVHTXHVWLRQV)OLSEDFNWKURXJK HDUOLHUSDJHVDQGFKDSWHUVLI\RXQHHGWREXW GRQ·WWXUQWKHSDJHXQWLO\RX·YHGRQHWKLV <HV\RX&$1JHWVHUYOHWLQLWSDUDPHWHUVIURPD VHUYOHWWKHTXHVWLRQVDUH +RZZRXOG\RXUHWULHYHWKHPLQ\RXUFRGH"%LJ KXJHJUDYHOKDXOLQJKLQWSUHWW\FORVHWRWKHVDPH ZD\\RXUHWULHYHWKHPLQD´QRUPDOµVHUYOHW)URP ZKLFKREMHFWGR\RXQRUPDOO\JHWVHUYOHWLQLWSDUDP HWHUV",VWKDWREMHFWDYDLODEOHWR\RXU-63FRGH" +RZZKHUHZRXOG\RXFRQILJXUHWKHVHUYOHWLQLW SDUDPHWHUV" 6XSSRVH\RXGRZDQWWRRYHUULGHWKHLQLW PHWKRGKRZZRXOG\RXGRLW",VWKHUHVRPHWKLQJ HOVH\RXFDQGRWKDW·OOJLYH\RXWKHVDPHUHVXOW" Chapter 7. Being a JSP Chapter 7. Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 0596005407 Publisher: O'Reilly Prepared for Augusto Jaramillo Forcada, Safari ID: augustojf.cv@gmail.com Print Publication Date: 8/1/2004 User number: 729515 Copyright 2007, Safari Books Online, LLC. This 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 without 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.  FKDSWHU 1VQ\QITQbQVOaW]Z2;8 9OUCANDOSERVLETINITIALIZATIONSTUFFINYOUR*30BUTITSSLIGHTLY DIFFERENTFROMWHATYOUDOINAREGULARSERVLET 2YHUULGLQJMVS,QLW 9ESITSTHATSIMPLE)FYOUIMPLEMENTAJSP)NITMETHODTHE#ONTAINERCALLSTHIS METHODATTHEBEGINNINGOFTHISPAGESLIFEASASERVLET)TSCALLEDFROMTHESERVLETS INITMETHODSOBYTHETIMETHISMETHODRUNSTHEREISA3ERVLET#ONlGAND 3ERVLET#ONTEXTAVAILABLETOTHESERVLET4HATMEANSYOUCANCALLGET3ERVLET#ONlG ANDGET3ERVLET#ONTEXTFROMWITHINTHEJSP)NITMETHOD 4HISEXAMPLEUSESTHEJSP)NITMETHODTORETRIEVEASERVLETINITPARAMETER CONlGUREDINTHE$$ANDUSESTHEVALUETOSETANAPPLICATIONSCOPEDATTRIBUTE  SXEOLFYRLG MVS,QLW^ 6HUYOHW&RQ¿JV&RQ¿J JHW6HUYOHW&RQ¿J 6WULQJHPDLO$GGU V&RQ¿JJHW,QLW3DUDPHWHU³HPDLO´ 6HUYOHW&RQWH[WFW[ JHW6HUYOHW&RQWH[W FW[VHW$WWULEXWH³PDLO´HPDLO$GGU ` ! Override the jspInit() method using a declaration. YouÕre in a servlet, so you can call your inherited getServletConÞg() method! &RQÀJXULQJVHUYOHWLQLWSDUDPHWHUV 9OUCONlGURESERVLETINITPARAMSFORYOUR*30VIRTUALLYTHESAMEWAYYOU CONlGURETHEMFORANORMALSERVLET4HEONLYDIFFERENCEISTHATYOUHAVE TOADDAJSPlLEELEMENTWITHINTHESERVLETTAG ZHEDSS!  VHUYOHW! VHUYOHWQDPH!0\7HVW,QLWVHUYOHWQDPH!  MVS¿OH!7HVW,QLWMVSMVS¿OH! LQLWSDUDP! SDUDPQDPH!HPDLOSDUDPQDPH! SDUDPYDOXH!LNLFNHGEXWW#ZLFNHGO\VPDUWFRPSDUDPYDOXH! LQLWSDUDP! VHUYOHW!  ZHEDSS! This is EXACTLY what youÕd do in a normal servlet. Get a reference to the ServletContext and set an application-scope attribute. This is the only line thatÕs different from a regular servlet. It basically says, Òapply everything in this <servlet> tag to the servlet created from this JSP page Ó RYHUULGLQJMVS,QLW Chapter 7. Being a JSP Chapter 7. Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 0596005407 Publisher: O'Reilly Prepared for Augusto Jaramillo Forcada, Safari ID: augustojf.cv@gmail.com Print Publication Date: 8/1/2004 User number: 729515 Copyright 2007, Safari Books Online, LLC. This 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 without 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. XVLQJ-63 \RXDUHKHUH  )\\ZQJ]\M[QVI2;8 4HEEXAMPLEONTHEOPPOSITEPAGESHOWSTHE*30SETTINGANAPPLICATIONSCOPED ATTRIBUTEUSINGAMETHODDECLARATIONTHATOVERRIDESJSP)NIT"UTMOSTOFTHE TIMEYOULLBEUSINGONEOFTHEFOURIMPLICITOBJECTSTOGETANDSETATTRIBUTES CORRESPONDINGTOTHEFOURATTRIBUTESCOPESAVAILABLEINA*30 9ESFOUR2EMEMBERINADDITIONTOTHESTANDARDSERVLETREQUESTSESSIONAND APPLICATIONCONTEXTSCOPESA*30ADDSAFOURTHSCOPEPAGESCOPETHATYOUGET FROMAPAGE#ONTEXTOBJECT 9OUUSUALLYWONTNEEDORCAREABOUTPAGESCOPEUNLESSYOUREDEVELOPING CUSTOMTAGSSOWEWONTSAYANYMOREABOUTITUNTILTHECUSTOMTAGSCHAPTER ,QDVHUYOHW ,QD-63 XVLQJLPSOLFLWREMHFWV $SSOLFDWLRQ JHW6HUYOHW&RQWH[WVHW$WWULEXWH´IRRµEDU2EM DSSOLFDWLRQVHW$WWULEXWH´IRRµEDU2EM 5HTXHVW UHTXHVWVHW$WWULEXWH´IRRµEDU2EM UHTXHVWVHW$WWULEXWH´IRRµEDU2EM 6HVVLRQ UHTXHVWJHW6HVVLRQVHW$WWULEXWH´IRRµEDU2EM VHVVLRQVHW$WWULEXWH´IRRµEDU2EM 3DJH 'RHVQRWDSSO\ SDJH&RQWH[WVHW$WWULEXWH´IRRµEDU2EM "UTTHISISNTTHEWHOLESTORY)NA*30THERESANOTHERWAYTOGETAND SETATTRIBUTESATANYSCOPEUSINGONLYTHEPAGE#ONTEXTIMPLICITOBJECT 4URNTHEPAGEANDlNDOUTHOW  7KHQDPLQJFRQYHQWLRQPLJKWWULFN\RXLQWRWKLQNLQJWKDWDWWULEXWHVVWRUHG LQWKH6HUYOHW&RQWH[WDUHFRQWH[WVFRSH%XWWKHUH¶VQRVXFKWKLQJ 5HPHPEHUZKHQ\RXVHH³&RQWH[W´WKLQN³DSSOLFDWLRQ´%XWWKHUH¶VDQ LQFRQVLVWHQF\EHWZHHQWKHVHUYOHWDQG-63QDPHVXVHGWRJHWDSS VFRSHGDWWULEXWHV²LQDVHUYOHW\RXVD\ JHW6HUYOHW&RQWH[WJHW$WWULEXWH³IRR´ EXWLQD-63\RXVD\ DSSOLFDWLRQJHW$WWULEXWH³IRR´ 7KHUH·VQRVXFKWKLQJDV´FRQWH[WµVFRSH HYHQWKRXJKDWWULEXWHVLQDSSOLFDWLRQVFRSH DUHERXQGWRWKH6HUYOHW&RQWH[WREMHFW Chapter 7. Being a JSP Chapter 7. Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 0596005407 Publisher: O'Reilly Prepared for Augusto Jaramillo Forcada, Safari ID: augustojf.cv@gmail.com Print Publication Date: 8/1/2004 User number: 729515 Copyright 2007, Safari Books Online, LLC. This 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 without 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.  FKDSWHU =[QVO8IOM+WV\M`\NWZI\\ZQJ]\M[ 9OUCANUSEA0AGE#ONTEXTREFERENCETOGETATTRIBUTES FROMANYSCOPEINCLUDINGTHEPAGESCOPEFORATTRIBUTES BOUNDTOTHE0AGE#ONTEXT 4HEMETHODSTHATWORKWITHOTHERSCOPESTAKEANINT ARGUMENTTOINDICATETHESCOPE!LTHOUGHTHEATTRIBUTE ACCESSMETHODSCOMEFROM*SP#ONTEXTYOULLlNDTHE CONSTANTSFORTHESCOPESINSIDETHE0AGE#ONTEXTCLASS JHW$WWULEXWH6WULQJQDPH JHW$WWULEXWH6WULQJQDPHLQWVFRSH JHW$WWULEXWH1DPHV,Q6FRSHLQWVFRSH ILQG$WWULEXWH6WULQJQDPH PRUHPHWKRGV LQFOXGLQJVLPLODUPHWKRGVWR VHWDQGUHPRYHDWWULEXWHVIURP DQ\VFRSH -VS&RQWH[W $33/,&$7,21B6&23( 3$*(B6&23( 5(48(67B6&23( 6(66,21B6&23( PRUHILHOGV JHW5HTXHVW JHW6HUYOHW&RQILJ JHW6HUYOHW&RQWH[W JHW6HVVLRQ PRUHPHWKRGV 3DJH&RQWH[W static Þ nal Þ elds methods that work for ANY scope methods to get any implicit object SDJH&RQWH[WDQGDWWULEXWHV Chapter 7. Being a JSP Chapter 7. Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 0596005407 Publisher: O'Reilly Prepared for Augusto Jaramillo Forcada, Safari ID: augustojf.cv@gmail.com Print Publication Date: 8/1/2004 User number: 729515 Copyright 2007, Safari Books Online, LLC. This 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 without 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 7 Being a JSP Chapter 7 Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 059 60 054 07 Publisher:Prepared for Augusto Jaramillo Forcada, Safari ID: augustojf.cv@gmail.com O'Reilly Print Publication Date: 8/1/2004 User number: 72 951 5 Copyright 2007, Safari Books Online, LLC This PDF is exclusively for your... violates the Safari Terms of Service is strictly prohibited Chapter 7 Being a JSP Chapter 7 Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 059 60 054 07 Publisher:Prepared for Augusto Jaramillo Forcada, Safari ID: augustojf.cv@gmail.com O'Reilly Print Publication Date: 8/1/2004 User number: 72 951 5 Copyright 2007, Safari Books Online, LLC This PDF is exclusively for your... violates the Safari Terms of Service is strictly prohibited Chapter 7 Being a JSP Chapter 7 Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 059 60 054 07 Publisher:Prepared for Augusto Jaramillo Forcada, Safari ID: augustojf.cv@gmail.com O'Reilly Print Publication Date: 8/1/2004 User number: 72 951 5 Copyright 2007, Safari Books Online, LLC This PDF is exclusively for your... violates the Safari Terms of Service is strictly prohibited Chapter 7 Being a JSP Chapter 7 Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 059 60 054 07 Publisher:Prepared for Augusto Jaramillo Forcada, Safari ID: augustojf.cv@gmail.com O'Reilly Print Publication Date: 8/1/2004 User number: 72 951 5 Copyright 2007, Safari Books Online, LLC This PDF is exclusively for your... violates the Safari Terms of Service is strictly prohibited Chapter 7 Being a JSP Chapter 7 Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 059 60 054 07 Publisher:Prepared for Augusto Jaramillo Forcada, Safari ID: augustojf.cv@gmail.com O'Reilly Print Publication Date: 8/1/2004 User number: 72 951 5 Copyright 2007, Safari Books Online, LLC This PDF is exclusively for your... violates the Safari Terms of Service is strictly prohibited Chapter 7 Being a JSP Chapter 7 Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 059 60 054 07 Publisher:Prepared for Augusto Jaramillo Forcada, Safari ID: augustojf.cv@gmail.com O'Reilly Print Publication Date: 8/1/2004 User number: 72 951 5 Copyright 2007, Safari Books Online, LLC This PDF is exclusively for your... violates the Safari Terms of Service is strictly prohibited Chapter 7 Being a JSP Chapter 7 Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 059 60 054 07 Publisher:Prepared for Augusto Jaramillo Forcada, Safari ID: augustojf.cv@gmail.com O'Reilly Print Publication Date: 8/1/2004 User number: 72 951 5 Copyright 2007, Safari Books Online, LLC This PDF is exclusively for your... violates the Safari Terms of Service is strictly prohibited Chapter 7 Being a JSP Chapter 7 Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 059 60 054 07 Publisher:Prepared for Augusto Jaramillo Forcada, Safari ID: augustojf.cv@gmail.com O'Reilly Print Publication Date: 8/1/2004 User number: 72 951 5 Copyright 2007, Safari Books Online, LLC This PDF is exclusively for your... violates the Safari Terms of Service is strictly prohibited Chapter 7 Being a JSP Chapter 7 Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 059 60 054 07 Publisher:Prepared for Augusto Jaramillo Forcada, Safari ID: augustojf.cv@gmail.com O'Reilly Print Publication Date: 8/1/2004 User number: 72 951 5 Copyright 2007, Safari Books Online, LLC This PDF is exclusively for your... violates the Safari Terms of Service is strictly prohibited Chapter 7 Being a JSP Chapter 7 Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 059 60 054 07 Publisher:Prepared for Augusto Jaramillo Forcada, Safari ID: augustojf.cv@gmail.com O'Reilly Print Publication Date: 8/1/2004 User number: 72 951 5 Copyright 2007, Safari Books Online, LLC This PDF is exclusively for your . created from this JSP page Ó RYHUULGLQJMVS,QLW Chapter 7. Being a JSP Chapter 7. Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 059 60 054 07 Publisher: O'Reilly Prepared. attribute is no longer in the JSP spec! Chapter 7. Being a JSP Chapter 7. Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 059 60 054 07 Publisher: O'Reilly Prepared. this!  ,W¶V127LQIURQWRIWKHRWKHUWZRPHWKRGV MVS,QLWDQGMVS'HVWUR7KLQNRILWWKLV ZDWKHXQGHUVFRUHLQIURQWRIWKHPHWKRG PHDQV³GRQ¶WWRXFK´ 6RQRXQGHUVFRUHLQIURQWRIWKHQDPH PHDQVRXFDQRYHUULGH%XWLIWKHUH,6 DQXQGHUVFRUHLQIURQWRIWKHPHWKRG QDPHRXPXVW127WUWRRYHUULGHLW 1RWHWKHXQGHUVFRUH DWWKHIURQWRIWKH B MVS6HUYLFHPHWKRG Chapter 7. Being a JSP Chapter 7. Being a JSP Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 059 60 054 07 Publisher: O'Reilly Prepared for

Ngày đăng: 12/08/2014, 19:20

TỪ KHÓA LIÊN QUAN