Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 74 trang
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 \RXDUHKHUH &RGH0DJQHWV $QVZHUV LPSRUW VHVVLRQ RXW LPSRUWMDYDXWLO # ^! ` KWPO!ERG\! $UUD\/LVW UHTXHVW SDJH $UUD\/LVW VHVVLRQ JHW3DUDPHWHU´QDPHVµ JHW$WWULEXWH³QDPHV´ ZKLOH JHW$WWULEXWH´KREE\µ DO UHTXHVW ! LWKDV1H[W LPSRUW ´MDYDXWLO´ JHW3DUDPHWHU³KREE\´ ,I\RXUDQVZHUORRNVDOLWWOHGLIIHUHQWEXW\RX VWLOOWKLQNLWVKRXOGZRUN³WU\LW<RX·OOKDYHWR PDNHWKHVHUYOHWWKDWWDNHVWKHIRUPUHTXHVW VHWVDQDWWULEXWHDQGIRUZDUGVGLVSDWFKHV WKHUHTXHVWWRWKH-63 ! 7KHIULHQGVZKRVKDUH\RXUKREE\RI DUHEU! UHTXHVW LWQH[W ! ,WHUDWRULW DOLWHUDWRU ! 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-ATHRANDOM Rhv R-ATHRANDOM R3TRINGShFOOv RNEW3TRING;= R R RFALSE RNEW#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 9DOLGDQG,QYDOLG([SUHVVLRQV YDOLGDQGLQYDOLGH[SUHVVLRQV )KWUUMV\ 9ESYOUCANPUTCOMMENTSINYOUR *30)FYOUREA*AVAPROGRAMMERWITH VERYLITTLE(4-,EXPERIENCEYOU MIGHTlNDYOURSELFTYPING THISISACOMMENT WITHOUTTHINKINGTWICE"UTIFYOU DOTHENUNLESSITSWITHINASCRIPTLET ORDECLARATIONTAGYOULLENDUP $)30,!9).'THATTOTHECLIENTASPART OFTHERESPONSE)NOTHERWORDSTOTHE #ONTAINERTHOSETWOSLASHESAREJUST MORETEMPLATETEXTLIKEh(ELLOvOR h%MAILISv 9OUCANPUTTWODIFFERENTTYPESOF COMMENTSINA*30 +70/FRPPHQW! 7KH&RQWDLQHUMXVWSDVVHVWKLVVWUDLJKWRQ WRWKHFOLHQWZKHUHWKHEURZVHULQWHUSUHWV LWDVDFRPPHQW -63FRPPHQW! 7KHVHDUHIRUWKHSDJHGHYHORSHUVDQG MXVWOLNH-DYDFRPPHQWVLQD-DYDVRXUFH ILOHWKH\·UHVWULSSHGRXWRIWKHWUDQVODWHG SDJH,I\RX·UHW\SLQJD-63DQGZDQWWR SXWLQFRPPHQWVDERXWZKDW\RX·UHGRLQJ WKHZD\\RX·GXVHFRPPHQWVLQD-DYD VRXUFHILOHXVHD-63FRPPHQW ,I\RXZDQWFRPPHQWVWRVWD\DVSDUW RIWKH+70/UHVSRQVHWRWKHFOLHQW DOWKRXJKWKHEURZVHUZLOOKLGHWKHPIURP WKHFOLHQW·VYLHZXVHDQ+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 \RXDUHKHUH )81NWZ\PMOMVMZI\ML[MZ^TM\ 4HE#ONTAINERGENERATESACLASSFROMYOUR*30THAT IMPLEMENTSTHE(TTP*SP0AGEINTERFACE4HISISTHEONLY PARTOFTHEGENERATEDSERVLETS!0)THATYOUNEEDTO KNOW9OUDONTCARETHATIN4OMCATFOREXAMPLEYOUR GENERATEDSERVLETEXTENDS RUJDSDFKHMDVSHUUXQWLPH+WWS-VS%DVH !LLYOUNEEDTOKNOWABOUTARETHETHREEKEYMETHODS MVS,QLW MVS'HVWUR\ LQWHUIDFH!! MDYD[VHUYOHWMVS-VS3DJH BMVS6HUYLFH+WWS6HUYOHW5HTXHVW+WWS6HUYOHW5HVSRQVH LQWHUIDFH!! MDYD[VHUYOHWMVS+WWS-VS3DJH MVS,QLW 7KLVPHWKRGLVFDOOHGIURPWKHLQLWPHWKRG <RXFDQRYHUULGHWKLVPHWKRG&DQ\RXILJXUHRXWKRZ" MVS'HVWUR\ 7KLVPHWKRGLVFDOOHGIURPWKHVHUYOHW·VGHVWUR\PHWKRG <RXFDQRYHUULGHWKLVPHWKRGDVZHOO BMVS6HUYLFH 7KLVPHWKRGLVFDOOHGIURPWKHVHUYOHW·VVHUYLFHPHWKRG ZKLFKPHDQVLWUXQVLQDVHSDUDWHWKUHDGIRUHDFKUHTXHVW 7KH&RQWDLQHUSDVVHVWKH5HTXHVWDQG5HVSRQVHREMHFWVWR WKLVPHWKRG <RXFDQ·WRYHUULGHWKLVPHWKRG<RXFDQ·WGR$1<7+,1*ZLWK WKLVPHWKRG\RXUVHOIH[FHSWZULWHFRGHWKDWJRHVLQVLGHLW DQGLW·VXSWRWKH&RQWDLQHUYHQGRUWRWDNH\RXU-63FRGH DQGIDVKLRQWKHBMVS6HUYLFHPHWKRGWKDWXVHVLW You can override these. You CANNOT override this! ,W¶V127LQIURQWRIWKHRWKHUWZRPHWKRGV MVS,QLWDQGMVS'HVWUR\7KLQNRILWWKLV ZD\WKHXQGHUVFRUHLQIURQWRIWKHPHWKRG PHDQV³GRQ¶WWRXFK´ 6RQRXQGHUVFRUHLQIURQWRIWKHQDPH PHDQV\RXFDQRYHUULGH%XWLIWKHUH,6 DQXQGHUVFRUHLQIURQWRIWKHPHWKRG QDPH\RXPXVW127WU\WRRYHUULGHLW 1RWHWKHXQGHUVFRUH DWWKHIURQWRIWKH B MVS6HUYLFHPHWKRG 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 4QNMKaKTMWNI2;8 9OUWRITETHEJSPlLE 4HE#ONTAINERWRITESTHEJAVAlLEFORTHESERVLETYOUR*30BECOMES :HE&RQWDLQHU .LPZULWHVDMVSÀOH DQGGHSOR\VLWDV SDUWRIDZHEDSS 7KH&RQWDLQHU´UHDGVµWKHZHE[PO''IRU WKLVDSSEXWGRHVQ·WGRDQ\WKLQJHOVHZLWKWKH MVSÀOHXQWLOWKHÀUVWWLPHLW·VUHTXHVWHG "[POYHU VLRQ ´´ HQFRGLQJ ´87)´"! '2&7<3( ZHE[PO :HE&RQWDLQHU 7KHFOLHQWKLWVDOLQN WKDWDVNVIRUWKHMVS 7KH&RQWDLQHUWULHVWR75$16/$7(WKHMVS LQWRMDYDVRXUFHFRGHIRUDVHUYOHWFODVV 0\-63BMVSFODVV SDFNDJHRUJ DSDFKH LPSRUW MD YD[VHUYOHW +WWS6HUY OHW 0\-63BMVSMDYD KWPO! ERG\! LQW[! +HOOR [! ERG\! KWPO! 0\-63MVS WUDQVODWH UHTXHVW JHQHUDWH :HE&RQWDLQHU 7KH&RQWDLQHUWULHVWR&203,/(WKH VHUYOHWMDYDVRXUFHLQWRDFODVVÀOH FRPSLOH JHQHUDWH JSP syntax errors are caught in this phase. Java language/syntax errors are caught here. -63OLIHF\FOH KWPO! ERG\! LQW[! +HOOR [! ERG\! KWPO! 0\-63MVS ItÕs just sitting here on the server waiting for a client to request it. SDFNDJHRUJ DSDFKH LPSRUW MD YD[VHUYOHW +WWS6HUY OHW 0\-63BMVSMDYD 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 \RXDUHKHUH :HE&RQWDLQHU 7KH&RQWDLQHU/2$'6WKH QHZO\JHQHUDWHGVHUYOHWFODVV :HE&RQWDLQHU 7KH&RQWDLQHULQVWDQWLDWHVWKH VHUYOHWDQGFDXVHVWKHVHUYOHW·V MVS,QLWPHWKRGWRUXQ MVS,QLW 7KH&RQWDLQHUFUHDWHVDQHZWKUHDGWR KDQGOHWKLVFOLHQW·VUHTXHVWDQGWKH VHUYOHW·VBMVS6HUYLFHPHWKRGUXQV :HE&RQWDLQHU 0\-63BMVSFODVV ORDG 0\-63B MVS 0 \ - 6 3 B M V S EHFRPHV 7KHREMHFWLVQRZDIXOOÁHGJHGVHUYOHW UHDG\WRDFFHSWFOLHQWUHTXHVWV 0\-63B MVS BMVS6HUYLFH (YHU\WKLQJWKDWKDSSHQVDIWHU WKLVLVMXVWSODLQROGVHUYOHW UHTXHVWKDQGOLQJ (YHQWXDOO\WKHVHUYOHWVHQGVD UHVSRQVHEDFNWRWKHFOLHQWRU IRUZDUGVWKHUHTXHVWWRDQRWKHU ZHEDSSFRPSRQHQW 2;8TQNMKaKTMKWV\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\QWVIVLKWUXQTI\QWV PIXXMV[WVTa76+- 7HENYOUDEPLOYAWEBAPPWITHA*30THE WHOLETRANSLATIONANDCOMPILATIONSTEPHAPPENS ONLYONCEINTHE*30SLIFE/NCEITSBEEN TRANSLATEDANDCOMPILEDITSJUSTLIKEANYOTHER SERVLET!NDJUSTLIKEANYOTHERSERVLETONCETHAT SERVLETHASBEENLOADEDANDINITIALIZEDTHEONLY THINGTHATHAPPENSATREQUESTTIMEISCREATIONOR ALLOCATIONOFATHREADFORTHESERVICEMETHOD3O THEPICTUREONTHEPREVIOUSTWOPAGESISFORONLY THElRSTREQUEST :RZ,DPWUXO\LPSUHVVHG, ZRXOGQHYHUKDYHJXHVVHGWKDW WKH\FRXOGPDNHUHTXHVWLQJD-63 WDNHMXVWDVPXFKRYHUKHDGDVFDOOLQJD PHWKRGRQDQ(-%,·PWKLQNLQJWKHFOLHQW KDVWRZDLWZKDW ÀYHPLQXWHV IRUDOO WKDWWUDQVODWLQJFRPSLOLQJDQG LQLWLDOL]LQJ" 4 /+SOTHATMEANSONLYTHElRSTCLIENTTOASK FORTHE*30TAKESTHEBIGHIT"UTTHERE-534BEA WAYTOCONlGURETHESERVERTOPRETRANSLATEAND COMPILERIGHT $ !LTHOUGHITSONLYTHEFIRSTCLIENTTHATHASTO WAITMOST#ONTAINERVENDORS$/GIVEYOUAWAYTOASK FORTHEWHOLETRANSLATIONCOMPILATIONTHINGTOHAPPEN INADVANCESOTHATEVENTHEFIRSTREQUESTHAPPENSLIKE ANYOTHERSERVLETREQUEST "UTWATCHOUTITSVENDORDEPENDENTANDNOT GUARANTEED4HERE)3AMENTIONINTHE*30SPEC*30 OFASUGGESTEDPROTOCOLFOR*30PRECOMPILATION 9OUMAKEAREQUESTFORTHE*30APPENDINGAQUERY STRINGhJSP?PRECOMPILEvANDTHE#ONTAINERMIGHTIF ITCHOOSESDOTHETRANSLATIONCOMPILATIONRIGHTTHEN INSTEADOFWAITINGFORTHEFIRSTREALREQUEST WUDQVODWLRQDQG 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 \RXDUHKHUH ,IWKH-63WXUQVLQWRD VHUYOHW,ZRQGHULI,FDQ FRQÀJXUHVHUYOHWLQLWSDUDPHWHUV DQGZKLOH,·PDWLW,ZRQGHULI,FDQ RYHUULGHWKHVHUYOHW·VLQLWPHWKRG 6KDUSHQ \RXU SHQFLO 7KLQNDERXWWKHVHTXHVWLRQV)OLSEDFNWKURXJK HDUOLHUSDJHVDQGFKDSWHUVLI\RXQHHGWREXW GRQ·WWXUQWKHSDJHXQWLO\RX·YHGRQHWKLV <HV\RX&$1JHWVHUYOHWLQLWSDUDPHWHUVIURPD VHUYOHWWKHTXHVWLRQVDUH +RZZRXOG\RXUHWULHYHWKHPLQ\RXUFRGH"%LJ KXJHJUDYHOKDXOLQJKLQWSUHWW\FORVHWRWKHVDPH ZD\\RXUHWULHYHWKHPLQD´QRUPDOµVHUYOHW)URP ZKLFKREMHFWGR\RXQRUPDOO\JHWVHUYOHWLQLWSDUDP HWHUV",VWKDWREMHFWDYDLODEOHWR\RXU-63FRGH" +RZZKHUHZRXOG\RXFRQILJXUHWKHVHUYOHWLQLW SDUDPHWHUV" 6XSSRVH\RXGRZDQWWRRYHUULGHWKHLQLW PHWKRGKRZZRXOG\RXGRLW",VWKHUHVRPHWKLQJ HOVH\RXFDQGRWKDW·OOJLYH\RXWKHVDPHUHVXOW" 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\QITQbQVOaW]Z2;8 9OUCANDOSERVLETINITIALIZATIONSTUFFINYOUR*30BUTITSSLIGHTLY DIFFERENTFROMWHATYOUDOINAREGULARSERVLET 2YHUULGLQJMVS,QLW 9ESITSTHATSIMPLE)FYOUIMPLEMENTAJSP)NITMETHODTHE#ONTAINERCALLSTHIS METHODATTHEBEGINNINGOFTHISPAGESLIFEASASERVLET)TSCALLEDFROMTHESERVLETS INITMETHODSOBYTHETIMETHISMETHODRUNSTHEREISA3ERVLET#ONlGAND 3ERVLET#ONTEXTAVAILABLETOTHESERVLET4HATMEANSYOUCANCALLGET3ERVLET#ONlG ANDGET3ERVLET#ONTEXTFROMWITHINTHEJSP)NITMETHOD 4HISEXAMPLEUSESTHEJSP)NITMETHODTORETRIEVEASERVLETINITPARAMETER CONlGUREDINTHE$$ANDUSESTHEVALUETOSETANAPPLICATIONSCOPEDATTRIBUTE SXEOLFYRLG MVS,QLW^ 6HUYOHW&RQ¿JV&RQ¿J JHW6HUYOHW&RQ¿J 6WULQJHPDLO$GGU V&RQ¿JJHW,QLW3DUDPHWHU³HPDLO´ 6HUYOHW&RQWH[WFW[ 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ÀJXULQJVHUYOHWLQLWSDUDPHWHUV 9OUCONlGURESERVLETINITPARAMSFORYOUR*30VIRTUALLYTHESAMEWAYYOU CONlGURETHEMFORANORMALSERVLET4HEONLYDIFFERENCEISTHATYOUHAVE TOADDAJSPlLEELEMENTWITHINTHESERVLETTAG ZHEDSS! VHUYOHW! VHUYOHWQDPH!0\7HVW,QLWVHUYOHWQDPH! MVS¿OH!7HVW,QLWMVSMVS¿OH! LQLWSDUDP! SDUDPQDPH!HPDLOSDUDPQDPH! SDUDPYDOXH!LNLFNHGEXWW#ZLFNHGO\VPDUWFRPSDUDPYDOXH! LQLWSDUDP! VHUYOHW! ZHEDSS! 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 Ó RYHUULGLQJMVS,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 \RXDUHKHUH )\\ZQJ]\M[QVI2;8 4HEEXAMPLEONTHEOPPOSITEPAGESHOWSTHE*30SETTINGANAPPLICATIONSCOPED ATTRIBUTEUSINGAMETHODDECLARATIONTHATOVERRIDESJSP)NIT"UTMOSTOFTHE TIMEYOULLBEUSINGONEOFTHEFOURIMPLICITOBJECTSTOGETANDSETATTRIBUTES CORRESPONDINGTOTHEFOURATTRIBUTESCOPESAVAILABLEINA*30 9ESFOUR2EMEMBERINADDITIONTOTHESTANDARDSERVLETREQUESTSESSIONAND APPLICATIONCONTEXTSCOPESA*30ADDSAFOURTHSCOPEPAGESCOPETHATYOUGET FROMAPAGE#ONTEXTOBJECT 9OUUSUALLYWONTNEEDORCAREABOUTPAGESCOPEUNLESSYOUREDEVELOPING CUSTOMTAGSSOWEWONTSAYANYMOREABOUTITUNTILTHECUSTOMTAGSCHAPTER ,QDVHUYOHW ,QD-63 XVLQJLPSOLFLWREMHFWV $SSOLFDWLRQ JHW6HUYOHW&RQWH[WVHW$WWULEXWH´IRRµEDU2EM DSSOLFDWLRQVHW$WWULEXWH´IRRµEDU2EM 5HTXHVW UHTXHVWVHW$WWULEXWH´IRRµEDU2EM UHTXHVWVHW$WWULEXWH´IRRµEDU2EM 6HVVLRQ UHTXHVWJHW6HVVLRQVHW$WWULEXWH´IRRµEDU2EM VHVVLRQVHW$WWULEXWH´IRRµEDU2EM 3DJH 'RHVQRWDSSO\ SDJH&RQWH[WVHW$WWULEXWH´IRRµEDU2EM "UTTHISISNTTHEWHOLESTORY)NA*30THERESANOTHERWAYTOGETAND SETATTRIBUTESATANYSCOPEUSINGONLYTHEPAGE#ONTEXTIMPLICITOBJECT 4URNTHEPAGEANDlNDOUTHOW 7KHQDPLQJFRQYHQWLRQPLJKWWULFN\RXLQWRWKLQNLQJWKDWDWWULEXWHVVWRUHG LQWKH6HUYOHW&RQWH[WDUHFRQWH[WVFRSH%XWWKHUH¶VQRVXFKWKLQJ 5HPHPEHUZKHQ\RXVHH³&RQWH[W´WKLQN³DSSOLFDWLRQ´%XWWKHUH¶VDQ LQFRQVLVWHQF\EHWZHHQWKHVHUYOHWDQG-63QDPHVXVHGWRJHWDSS VFRSHGDWWULEXWHV²LQDVHUYOHW\RXVD\ JHW6HUYOHW&RQWH[WJHW$WWULEXWH³IRR´ EXWLQD-63\RXVD\ DSSOLFDWLRQJHW$WWULEXWH³IRR´ 7KHUH·VQRVXFKWKLQJDV´FRQWH[WµVFRSH HYHQWKRXJKDWWULEXWHVLQDSSOLFDWLRQVFRSH DUHERXQGWRWKH6HUYOHW&RQWH[WREMHFW 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 =[QVO8IOM+WV\M`\NWZI\\ZQJ]\M[ 9OUCANUSEA0AGE#ONTEXTREFERENCETOGETATTRIBUTES FROMANYSCOPEINCLUDINGTHEPAGESCOPEFORATTRIBUTES BOUNDTOTHE0AGE#ONTEXT 4HEMETHODSTHATWORKWITHOTHERSCOPESTAKEANINT ARGUMENTTOINDICATETHESCOPE!LTHOUGHTHEATTRIBUTE ACCESSMETHODSCOMEFROM*SP#ONTEXTYOULLlNDTHE CONSTANTSFORTHESCOPESINSIDETHE0AGE#ONTEXTCLASS JHW$WWULEXWH6WULQJQDPH JHW$WWULEXWH6WULQJQDPHLQWVFRSH JHW$WWULEXWH1DPHV,Q6FRSHLQWVFRSH ILQG$WWULEXWH6WULQJQDPH PRUHPHWKRGV LQFOXGLQJVLPLODUPHWKRGVWR VHWDQGUHPRYHDWWULEXWHVIURP DQ\VFRSH -VS&RQWH[W $33/,&$7,21B6&23( 3$*(B6&23( 5(48(67B6&23( 6(66,21B6&23( PRUHILHOGV JHW5HTXHVW JHW6HUYOHW&RQILJ JHW6HUYOHW&RQWH[W JHW6HVVLRQ PRUHPHWKRGV 3DJH&RQWH[W static Þ nal Þ elds methods that work for ANY scope methods to get any implicit object SDJH&RQWH[WDQGDWWULEXWHV 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 Ó RYHUULGLQJMVS,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¶V127LQIURQWRIWKHRWKHUWZRPHWKRGV MVS,QLWDQGMVS'HVWUR7KLQNRILWWKLV ZDWKHXQGHUVFRUHLQIURQWRIWKHPHWKRG PHDQV³GRQ¶WWRXFK´ 6RQRXQGHUVFRUHLQIURQWRIWKHQDPH PHDQVRXFDQRYHUULGH%XWLIWKHUH,6 DQXQGHUVFRUHLQIURQWRIWKHPHWKRG QDPHRXPXVW127WUWRRYHUULGHLW 1RWHWKHXQGHUVFRUH DWWKHIURQWRIWKH B MVS6HUYLFHPHWKRG 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