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,48 MB
Nội dung
FKDSWHU AW]KIV][MVM[\MLM`XZM[[QWV[ QV[QLM\PMJZIKSM\[ MDYDXWLO0DSPXVLF0DS QHZMDYDXWLO+DVK0DS PXVLF0DSSXW³$PELHQW´³=HUR´ PXVLF0DSSXW³6XUI´³7DKLWL´ PXVLF0DSSXW³'-´³%7´ PXVLF0DSSXW³,QGLH´³)URX)URX´ UHTXHVWVHW$WWULEXWH³PXVLF0DS´PXVLF0DS 6WULQJ>@PXVLF7\SHV ^³$PELHQW´³6XUI´³'-´³,QGLH´` UHTXHVWVHW$WWULEXWH³0XVLF7\SH´PXVLF7\SHV 0XVLFLV^PXVLF0DS>0XVLF7\SH>@@` ,QDVHUYOHW 7KLV'2(6ZRUNLQD-63 KWWSORFDOKRVWWHVW-637HVWHUGR 0XVLFLV=HUR 0XVLFLV^PXVLF0DS>³$PELHQW´@` )TSEXPRESSIONSALLTHEWAYDOWNIN%,9OUNEST EXPRESSIONSTOANYARBITRARYLEVEL)NOTHERWORDSYOUCAN PUTACOMPLEXEXPRESSIONINSIDEACOMPLEXEXPRESSION INSIDEAITKEEPSGOING!NDTHEEXPRESSIONSARE EVALUATEDFROMTHEINNERMOSTBRACKETSOUT 4HISPARTWILLSEEMCOMPLETELYINTUITIVETOYOUBECAUSE ITSNODIFFERENTTHANNESTING*AVACODEWITHINPARENS4HE TRICKYPARTISTOWATCHOUTFORQUOTESVSNOQUOTES 0XVLFLV=HUR becomes becomes QHVWHGH[SUHVVLRQV Chapter 8. Script-free pages Chapter 8. Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 0596005407 Publisher: O'Reilly Prepared for Stephen Goss, Safari ID: stephengoss@gmx.net Print Publication Date: 8/1/2004 User number: 747221 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. VFULSWOHVV-63V \RXDUHKHUH AW]KIV¼\LW^IRR` 7ITHBEANSAND-APSYOUCANUSETHEDOTOPERATORBUTONLYIFTHE THINGYOUTYPEAFTERTHEDOTISALEGAL*AVAIDENTIFER 7KLV ^PXVLF0DS$PELHQW` ,VWKHVDPHDV WKLV ^PXVLF0DS>³$PELHQW´@` %XW WKLV ^PXVLF/LVW>³´@` &$1127EHWXUQHGLQWR WKLV ^PXVLF/LVW` NO! NO! NO! works works ,I\RXZRXOGQ·WXVHLWIRUD YDULDEOHQDPHLQ\RXU-DYDFRGH '21·7SXWLWDIWHUWKHGRW 6KDUSHQ \RXU SHQFLO MDYDXWLO$UUD\/LVWQXPV QHZMDYDXWLO$UUD\/LVW QXPVDGG³´ QXPVDGG³´ QXPVDGG³´ UHTXHVWVHW$WWULEXWH³QXPEHUV´QXPV 6WULQJ>@IDYRULWH0XVLF ^³=HUR´³7DKLWL´³%7´³)URX)URX´` UHTXHVWVHW$WWULEXWH³PXVLF/LVW´IDYRULWH0XVLF ^PXVLF/LVW>QXPEHUV>@@` ^PXVLF/LVW>QXPEHUV>@@` ^PXVLF/LVW>QXPEHUV>³´@@` ^PXVLF/LVW>QXPEHUV>QXPEHUV>@@@` :KDWSULQWV" *LYHQWKHVHUYOHWFRGHEHORZ¿JXUHRXWZKDWZRXOGSULQWRULIWKHUH¶GEHDQHUURU MXVWZULWH\RXNQRZ³HUURU´$QVZHUVDUHDWWKHERWWRPRIWKHQH[WSDJH (WeÕll talk more about EL operators in a few pages.) Chapter 8. Script-free pages Chapter 8. Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 0596005407 Publisher: O'Reilly Prepared for Stephen Goss, Safari ID: stephengoss@gmx.net Print Publication Date: 8/1/2004 User number: 747221 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 $ONTBESURPRISEDIFYOUlNDSOMETHINGLIKE THISONTHEEXAMEXCEPTINTHEREALEXAMITLL LOOKUGLIER 3TUDYTHETHREECLASSESONTHEPAGEAND THESERVLETCODEONTHEOPPOSITEPAGETHEN CONSTRUCTTHECODEMAGNETSTOMAKETHE%, THATLLPRODUCETHERESPONSESHOWNINTHE BROWSER4URNTHEPAGEFORTHEANSWERSBUT NOTUNTILYOU$/4()3ESPECIALLYIFYOURE GOINGTOTAKETHEEXAM SDFNDJHIRR SXEOLFFODVV'RJ^ SULYDWH6WULQJQDPH SULYDWH7R\>@WR\V SXEOLFYRLGVHW1DPH6WULQJQDPH^ WKLVQDPH QDPH ` SXEOLF6WULQJJHW1DPH^ UHWXUQQDPH ` SXEOLFYRLGVHW7R\V7R\>@WR\V^ WKLVWR\V WR\V ` SXEOLF7R\>@JHW7R\V^ UHWXUQWR\V ` ` IRR'RJ SDFNDJHIRR SXEOLFFODVV3HUVRQ^ SULYDWH'RJGRJ SULYDWH6WULQJQDPH SXEOLFYRLGVHW'RJ'RJGRJ^ WKLVGRJ GRJ ` SXEOLF'RJJHW'RJ^ UHWXUQGRJ ` SXEOLFYRLGVHW1DPH6WULQJQDPH^ WKLVQDPH QDPH ` SXEOLF6WULQJJHW1DPH^ UHWXUQQDPH ` ` IRR3HUVRQ SDFNDJHIRR SXEOLFFODVV7R\^ SULYDWH6WULQJQDPH SXEOLFYRLGVHW1DPH6WULQJQDPH^ WKLVQDPH QDPH ` SXEOLF6WULQJJHW1DPH^ UHWXUQQDPH ` ` IRR7R\ &RGH0DJQHWV $QVZHUVWR6KDUSHQRQSUHYLRXVSDJH7DKLWL%7)U RX)URX)URX)URX ELJH[HUFLVHRQ(/ Chapter 8. Script-free pages Chapter 8. Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 0596005407 Publisher: O'Reilly Prepared for Stephen Goss, Safari ID: stephengoss@gmx.net Print Publication Date: 8/1/2004 User number: 747221 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. VFULSWOHVV-63V \RXDUHKHUH IRR3HUVRQS QHZIRR3HUVRQ SVHW1DPH³/HHOX´ IRR'RJG QHZIRR'RJ GVHW1DPH³&O\GH´ IRR7R\W QHZIRR7R\ WVHW1DPH³VWLFN´ IRR7R\W QHZIRR7R\ WVHW1DPH³QHLJKERU¶VFDW´ IRR7R\W QHZIRR7R\ WVHW1DPH³%DUELHGROOKHDG´ GVHW7R\VQHZIRR7R\>@^WWW` SVHW'RJG UHTXHVWVHW$WWULEXWH³SHUVRQ´S 6HUYOHWFRGH KWWSORFDOKRVWWHVW-637HVWHUGR /HHOX¶VGRJ&O\GH¶VWR\VDUHVWLFN QHLJKERU¶VFDWDQGD%DUELHGROO KHDG &RPSRVHWKH(/IRUWKLVRXWSXW ¶V ^SHUVRQQDPH` GRJ ^SHUVRQGRJWR\V ^SHUVRQGRJQDPH` WR\VDUH ¶V ^SHUVRQGRJ ` >@ QDPH WR\V>@ QDPH ` DQGD ^SHUVRQ GRJ WR\V >@ QDPH ` QDPH WR\V WR\V WR\V ^SHUVRQGRJWR\VQDPH` ^SHUVRQGRJWR\VQDPH` WR\V ^SHUVRQGRJWR\V>³QDPH´@ WR\V>³QDPH´@ WR\V>³QDPH´@ >@ >@ Chapter 8. Script-free pages Chapter 8. Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 0596005407 Publisher: O'Reilly Prepared for Stephen Goss, Safari ID: stephengoss@gmx.net Print Publication Date: 8/1/2004 User number: 747221 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 IRR3HUVRQS QHZIRR(PSOR\HH SVHW1DPH³/HHOX´ IRR'RJG QHZIRR'RJ GVHW1DPH³&O\GH´ IRR7R\W QHZIRR7R\ WVHW1DPH³VWLFN´ IRR7R\W QHZIRR7R\ WVHW1DPH³QHLJKERU¶VFDW´ IRR7R\W QHZIRR7R\ WVHW1DPH³%DUELHGROOKHDG´ GVHW7R\VQHZIRR7R\>@^WWW` SVHW'RJG UHTXHVWVHW$WWULEXWH³SHUVRQ´S 6HUYOHWFRGH KWWSORFDOKRVWWHVW-637HVWHUGR /HHOX¶VGRJ&O\GH¶VWR\VDUH VWLFNQHLJKERU¶VFDWDQGD %DUELHGROOKHDG &RPSRVHWKH(/IRUWKLVRXWSXW ¶V ^SHUVRQQDPH`¶VGRJ^SHUVRQGRJQDPH`¶VWR\VDUH^SHUVRQGRJWR\V>@ QDPH`^SHUVRQGRJWR\V>@QDPH`DQGD^SHUVRQGRJWR\V>@QDPH` ^SHUVRQQDPH` GRJ ^SHUVRQGRJWR\V ^SHUVRQGRJQDPH` WR\VDUH¶V ^SHUVRQGRJ ` >@ QDPH WR\V>@ QDPH ` DQGD ^SHUVRQ GRJ WR\V >@ QDPH ` &RGH0DJQHWV $QVZHUV >@ >@ WR\V>³QDPH´@ ^SHUVRQGRJWR\V>³QDPH´@ WR\V ^SHUVRQGRJWR\VQDPH` ^SHUVRQGRJWR\VQDPH` WR\V WR\V WR\V QDPH H[HUFLVHDQVZHUV This is not the ONLY way to produce the output, but itÕs the only way using this set of magnets. Bonus exercise: write the EL expressions a little differently (forget the magnets), but print the same result. Chapter 8. Script-free pages Chapter 8. Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 0596005407 Publisher: O'Reilly Prepared for Stephen Goss, Safari ID: stephengoss@gmx.net Print Publication Date: 8/1/2004 User number: 747221 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. VFULSWOHVV-63V \RXDUHKHUH <PM-4QUXTQKQ\WJRMK\[ 2EMEMBER%,HASSOMEIMPLICITOBJECTS"UTTHESE ARENOTTHESAMEASTHE*30IMPLICITOBJECTSEXCEPT FORONEPAGE#ONTEXT(ERESAQUICKLISTWELLLOOK ATSOMEOFTHEMINMOREDETAILONTHENEXTFEWPAGES 9OULLNOTICETHATALLBUTONEPAGE#ONTEXTAGAINARE SIMPLE-APSNAMEVALUEPAIRS 5HPHPEHUWKDWP\+70/IRUP DFWLRQJRHVVWUDLJKWWRWKH -63LVWKHUHDZD\,FDQXVHWKH UHTXHVWSDUDPHWHUVMXVWXVLQJ(/" SDJH6FRSH UHTXHVW6FRSH VHVVLRQ6FRSH DSSOLFDWLRQ6FRSH SDUDP SDUDP9DOXHV KHDGHU KHDGHU9DOXHV FRRNLH LQLW3DUDP SDJH&RQWH[W A Map of the scope attributes. Maps of the request parameters. Maps of the request headers. Ooohhhh this is a tough one could it be a Map of cookies? A Map of the context init parameters (NOT servlet init parameters!) The only thing that is NOT a Map. This is the real dealÑan actual reference to the pageContext object, which you can think of as a bean. Look in the API for the PageContext getter methods. Chapter 8. Script-free pages Chapter 8. Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 0596005407 Publisher: O'Reilly Prepared for Stephen Goss, Safari ID: stephengoss@gmx.net Print Publication Date: 8/1/2004 User number: 747221 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 :MY]M[\XIZIUM\MZ[QV-4 0IECEOFCAKE4HEPARAMIMPLICITOBJECTISlNEWHENYOUKNOWYOUHAVEONLY ONEPARAMETERFORTHATPARTICULARPARAMETERNAME5SEPARAM6ALUESWHENYOU MIGHTHAVEMORETHANONEPARAMETERVALUEFORAGIVENPARAMETERNAME ,QWKH+70/IRUP IRUPDFWLRQ ´7HVW%HDQMVS´! 1DPHLQSXWW\SH ´WH[W´QDPH ´QDPH´! ,'LQSXWW\SH ´WH[W´QDPH ´HPS,'´! )LUVWIRRGLQSXWW\SH ´WH[W´QDPH ´IRRG´! 6HFRQGIRRGLQSXWW\SH ´WH[W´QDPH ´IRRG´! LQSXWW\SH ´VXEPLW´! IRUP! The ÒnameÓ and ÒempIDÓ will each have a single value. But the ÒfoodÓ parameter could have two values, if the user Þ lls in both Þ elds before hitting the submit button 5HTXHVWSDUDPQDPHLV^SDUDPQDPH`EU! 5HTXHVWSDUDPHPS,'LV^SDUDPHPS,'`EU! 5HTXHVWSDUDPIRRGLV^SDUDPIRRG`EU! )LUVWIRRGUHTXHVWSDUDP^SDUDP9DOXHVIRRG>@`EU! 6HFRQGIRRGUHTXHVWSDUDP^SDUDP9DOXHVIRRG>@`EU! 5HTXHVWSDUDPQDPH^SDUDP9DOXHVQDPH>@` KWWSORFDOKRVWWHVW-637HVWHUGR 5HTXHVWSDUDPQDPHLV)OXII\ 5HTXHVWSDUDPHPS,'LV 5HTXHVWSDUDPIRRGLV6XVKL )LUVWIRRGUHTXHVWSDUDP6XVKL 6HFRQGIRRGUHTXHVWSDUDP0DFDURQL &KHHVH 5HTXHVWSDUDPQDPH)OXII\ KWWSORFDOKRVWWHVW-637HVW%HDQMVS 1DPH ,' )LUVWIRRG 6HFRQGIRRG )OXII\ 6XVKL 0DFDURQL&KHHVH ,QWKH-63 ,QWKHFOLHQW·VEURZVHUFOLHQWÀOOVLQ WKHIRUPDQGKLWVWKHVXEPLWEXWWRQ 7KHUHVSRQVH Remember, param is just a Map of parameter names and values. The things to the right of the dot come from the names speciÞ ed in the input Þ elds of the form. Even though there might be multiple values for the ÒfoodÓ parameter, you can still use the single param implicit object, but youÕll get only the Þ rst value. SDUDPDQGSDUDP9DOXHV Chapter 8. Script-free pages Chapter 8. Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 0596005407 Publisher: O'Reilly Prepared for Stephen Goss, Safari ID: stephengoss@gmx.net Print Publication Date: 8/1/2004 User number: 747221 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. VFULSWOHVV-63V \RXDUHKHUH ?PI\QNaW]_IV\UWZMQVNWZUI\QWVNZWU\PMZMY]M[\' 7HATIFYOUWANTSAYTHESERVERHOSTINFORMATIONTHATCOMESWITHTHEhHOSTvHEADERIN THEREQUEST)FYOULOOKINTHE(TTP3ERVLET2EQUEST!0)YOUCANSEEAGET(EADER3TRING METHOD7EKNOWTHATIFWEPASShHOSTvTOTHEGET(EADERMETHODWELLGETBACK SOMETHINGLIKEhLOCALHOSTvBECAUSETHATSWHERETHEWEBSERVERIS :HNQRZZHFDQGRLWZLWK VFULSWLQJ +RVWLV UHTXHVWJHW+HDGHU³KRVW´! %XWZLWK(/ZH¶YHJRWWKHKHDGHULPSOLFLWREMHFW +RVWLV^KHDGHU>³KRVW´@` +RVWLV^KHDGHUKRVW` The header implicit object keeps a Map of all the headers. Use either access operator to pass in the header name and the value of that header will print. (Note: thereÕs also a headerValues implicit object for headers with multiple values. It works just like paramValues.) *HWWLQJWKH´KRVWµKHDGHU :HNQRZZHFDQGRLWZLWK VFULSWLQJ 0HWKRGLV UHTXHVWJHW0HWKRG! %XWZLWK(/ WKLV ZLOO127ZRUN 0HWKRGLV^UHTXHVWPHWKRG` *HWWLQJWKH+773UHTXHVWPHWKRG 5HOH4HISISALITTLETRICKIERTHERESAMETHODINTHE (TTP3ERVLET2EQUEST!0)FORGET-ETHODTHATRETURNS'%40/34ETC "UTHOWDO)GETITUSING%, NO! NO! NO! There IS no implicit request object! $QG WKLV ZLOO127ZRUN 0HWKRGLV^UHTXHVW6FRSHPHWKRG` NO! NO! NO! There IS an implicit requestScope, but itÕs NOT the request object itself. &DQ\RXÀJXUHRXWKRZWRGRLW" +LQWORRNDWWKHRWKHULPSOLFLWREMHFWV Chapter 8. Script-free pages Chapter 8. Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 0596005407 Publisher: O'Reilly Prepared for Stephen Goss, Safari ID: stephengoss@gmx.net Print Publication Date: 8/1/2004 User number: 747221 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 <PMZMY]M[\;KWXMQ[67<\PMZMY]M[\WJRMK\ 4HEIMPLICITREQUEST3COPEISJUSTA-APOFTHEREQUESTSCOPEATTRIBUTES NOTTHEREQUESTOBJECTITSELF7HATYOUWANTTHE(440METHODISA PROPERTYOFTHEREQUESTOBJECTNOTANATTRIBUTEATREQUESTSCOPE)NOTHER WORDSYOUWANTSOMETHINGTHATCOMESFROMCALLINGAGETTERMETHODON THEREQUESTOBJECTIFWETREATTHEREQUESTOBJECTLIKEABEAN "UTTHEREISNOREQUESTIMPLICITOBJECTONLYREQUEST3COPE7HATTODO 9OUNEEDSOMETHINGELSE 8VHUHTXHVW6FRSHWRJHWUHTXHVW $775,%87(6QRWUHTXHVW3523(57,(6 )RUUHTXHVWSURSHUWLHV\RXQHHGWRJR WKURXJKSDJH&RQWH[W 0HWKRGLV^SDJH&RQWH[WUHTXHVWPHWKRG` 8VHSDJH&RQWH[WWRJHWWRHYHU\WKLQJHOVH SDJH&RQWH[W KDVD UHTXHVW SURSHUW\ UHTXHVW KDVD PHWKRG SURSHUW\ ,W¶VVRHDV\WRWKLQNWKDWVD\DSSOLFDWLRQ6FRSHLVDUHIHUHQFHWR6HUY OHW&RQWH[WVLQFHWKDW¶VZKHUHDSSOLFDWLRQVFRSHGDWWULEXWHVDUHERXQG %XWMXVWDVZLWKUHTXHVW6FRSHDQGWKHUHTXHVWREMHFWWKHVFRSH0DSIRU DSSOLFDWLRQVFRSHGDWWULEXWHVLVMXVWWKDW²D0DSRIDWWULEXWHVDQGQRWK LQJPRUH<RXFDQ¶WWUHDWLWOLNHD6HUYOHW&RQWH[WVRGRQ¶WH[SHFWWRJHW 6HUYOHW&RQWH[WSURSHUWLHVEDFNIURPWKHDSSOLFDWLRQ6FRSHLPSOLFLWREMHFW 'RQ·WFRQIXVHWKH0DS VFRSH REMHFWVZLWKWKH REMHFWVWRZKLFKWKHDWWULEXWHVDUHERXQG VFRSHPDSVDUH127WKHUHDOREMHFW Chapter 8. Script-free pages Chapter 8. Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 0596005407 Publisher: O'Reilly Prepared for Stephen Goss, Safari ID: stephengoss@gmx.net Print Publication Date: 8/1/2004 User number: 747221 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. VFULSWOHVV-63V \RXDUHKHUH ;KWXMQUXTQKQ\WJRMK\[KIV[I^MaW] )FALLYOUNEEDISTOPRINTTHENAMEOFAPERSONANDYOUREALLY DONTCAREWHATSCOPETHEPERSONISINORYOUDOCAREBUT YOUKNOWTHERESONLYONEPERSONOUTOFALLFOURSCOPESYOU JUSTUSE /RIFYOUREWORRIEDABOUTAPOTENTIALNAMINGCONmICTYOU CANBEEXPLICITABOUTWHICHPERSONYOUWANT ^UHTXHVW6FRSHSHUVRQQDPH` "UTISTHEREANOTHERREASONYOUMIGHTHAVETOPREFACETHE ATTRIBUTEWITHTHEIMPLICITSCOPEOBJECT/THERTHANTO CONTROLSCOPING 4HINKABOUTTHISSCENARIOIFYOUHAVEANAMETHATSNOT INQUOTESINBRACKETS;=THATMEANSIT-534ADHERETO *AVANAMINGRULESRIGHT(EREWERE/+BECAUSEPERSON ISAPERFECTLYLEGAL*AVAVARIABLENAME"UTTHATSBECAUSE SOMEWHERESOMEONESAID UHTXHVWVHW$WWULEXWH³SHUVRQ´S "UTANATTRIBUTENAMEISA3TRING 3TRINGSDONTFOLLOW*AVAVARIABLENAMERULES 4HATMEANSSOMEONE COULD SAY UHTXHVWVHW$WWULEXWH³IRRSHUVRQ´S !NDTHENYOUDBEINTROUBLEBECAUSE4()3WONTWORK ^IRRSHUVRQQDPH` "UTYOULLBESOTHANKFULFORSCOPEOBJECTSBECAUSEUSINGA SCOPEOBJECTLETSYOUSWITCHTOTHE;=OPERATORTHATCANTAKE 3TRINGNAMESTHATDONTCONFORMTO*AVANAMINGRULES ,I(/ORRNVWKURXJKDOOWKH VFRSHVDQ\ZD\ZK\ZRXOG ,HYHUXVHRQHRIWKHVFRSH LPSOLFLWREMHFWV"7KHRQO\WKLQJ, FDQWKLQNRILVDQDPLQJFRQÁLFW EXW,ZRQGHULIWKHUHPLJKW EHDQRWKHUUHDVRQ ^SHUVRQQDPH` ^ UHTXHVW6FRSH>³IRRSHUVRQ´@QDPH` NO! This is certainly legal, but the Container just thinks that ÒfooÓ is an attribute somewhere, with a ÒpersonÓ property. But the Container never Þnds a ÒfooÓ attribute. Perfect! Using the requestScope object gives us a way to put the attribute name in quotes. Chapter 8. Script-free pages Chapter 8. Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 0596005407 Publisher: O'Reilly Prepared for Stephen Goss, Safari ID: stephengoss@gmx.net Print Publication Date: 8/1/2004 User number: 747221 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. [...]... 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 8 Script-free pages Chapter 8 Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 05 960 05407 Publisher: O'Reilly... 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 8 Script-free pages Chapter 8 Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 05 960 05407 Publisher: O'Reilly... 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 8 Script-free pages Chapter 8 Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 05 960 05407 Publisher: O'Reilly... 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 8 Script-free pages Chapter 8 Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 05 960 05407 Publisher: O'Reilly... 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 8 Script-free pages Chapter 8 Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 05 960 05407 Publisher: O'Reilly... 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 8 Script-free pages Chapter 8 Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 05 960 05407 Publisher: O'Reilly... 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 8 Script-free pages Chapter 8 Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 05 960 05407 Publisher: O'Reilly... 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 8 Script-free pages Chapter 8 Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 05 960 05407 Publisher: O'Reilly... 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 8 Script-free pages Chapter 8 Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 05 960 05407 Publisher: O'Reilly... 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 8 Script-free pages Chapter 8 Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 05 960 05407 Publisher: O'Reilly . when the JSP invokes the EL function. IXQ Chapter 8. Script-free pages Chapter 8. Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 05 960 05407 Publisher:. pages.) Chapter 8. Script-free pages Chapter 8. Script-free pages Head First Servlets and JSP By Bert Bates, Kathy Sierra, Bryan Basham ISBN: 05 960 05407 Publisher: O'Reilly Prepared for Stephen Goss,. QDPH ` SXEOLF6WULQJJHW1DPH^ UHWXUQQDPH ` ` IRR7R &RGH0DJQHWV $QVZHUVWR6KDUSHQRQSUHYLRXVSDJH7DKLWL%7)U RX)URX)URX)URX ELJH[HUFLVHRQ(/ Chapter 8. Script-free pages Chapter 8. Script-free pages Head First Servlets and JSP By Bert