Head First Servlets and JSP phần 6 ppt

74 248 0
Head First Servlets and JSP phần 6 ppt

Đ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

 FKDSWHU AW]KIV][MVM[\MLM`XZM[[QWV[ QV[QLM\PMJZIKSM\[ MDYDXWLO0DSPXVLF0DS QHZMDYDXWLO+DVK0DS PXVLF0DSSXW³$PELHQW´³=HUR´ PXVLF0DSSXW³6XUI´³7DKLWL´ PXVLF0DSSXW³'-´³%7´ PXVLF0DSSXW³,QGLH´³)URX)URX´ UHTXHVWVHW$WWULEXWH³PXVLF0DS´PXVLF0DS 6WULQJ>@PXVLF7\SHV ^³$PELHQW´³6XUI´³'-´³,QGLH´` UHTXHVWVHW$WWULEXWH³0XVLF7\SH´PXVLF7\SHV 0XVLFLV^PXVLF0DS>0XVLF7\SH>@@` ,QDVHUYOHW 7KLV'2(6ZRUNLQD-63 KWWSORFDOKRVWWHVW-637HVWHUGR 0XVLFLV=HUR 0XVLFLV^PXVLF0DS>³$PELHQW´@` )TSEXPRESSIONSALLTHEWAYDOWNIN%,9OUNEST EXPRESSIONSTOANYARBITRARYLEVEL)NOTHERWORDSYOUCAN PUTACOMPLEXEXPRESSIONINSIDEACOMPLEXEXPRESSION INSIDEAITKEEPSGOING!NDTHEEXPRESSIONSARE EVALUATEDFROMTHEINNERMOSTBRACKETSOUT 4HISPARTWILLSEEMCOMPLETELYINTUITIVETOYOUBECAUSE ITSNODIFFERENTTHANNESTING*AVACODEWITHINPARENS4HE TRICKYPARTISTOWATCHOUTFORQUOTESVSNOQUOTES 0XVLFLV=HUR becomes becomes QHVWHGH[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 \RXDUHKHUH  AW]KIV¼\LW^IRR` 7ITHBEANSAND-APSYOUCANUSETHEDOTOPERATORBUTONLYIFTHE THINGYOUTYPEAFTERTHEDOTISALEGAL*AVAIDENTIFER 7KLV ^PXVLF0DS$PELHQW` ,VWKHVDPHDV WKLV ^PXVLF0DS>³$PELHQW´@` %XW WKLV ^PXVLF/LVW>³´@` &$1127EHWXUQHGLQWR WKLV ^PXVLF/LVW` NO! NO! NO! works works ,I\RXZRXOGQ·WXVHLWIRUD YDULDEOHQDPHLQ\RXU-DYDFRGH '21·7SXWLWDIWHUWKHGRW 6KDUSHQ \RXU SHQFLO MDYDXWLO$UUD\/LVWQXPV QHZMDYDXWLO$UUD\/LVW QXPVDGG³´ QXPVDGG³´ QXPVDGG³´ UHTXHVWVHW$WWULEXWH³QXPEHUV´QXPV 6WULQJ>@IDYRULWH0XVLF ^³=HUR´³7DKLWL´³%7´³)URX)URX´` UHTXHVWVHW$WWULEXWH³PXVLF/LVW´IDYRULWH0XVLF ^PXVLF/LVW>QXPEHUV>@@` ^PXVLF/LVW>QXPEHUV>@@` ^PXVLF/LVW>QXPEHUV>³´@@` ^PXVLF/LVW>QXPEHUV>QXPEHUV>@@@` :KDWSULQWV" *LYHQWKHVHUYOHWFRGHEHORZ¿JXUHRXWZKDWZRXOGSULQWRULIWKHUH¶GEHDQHUURU MXVWZULWH\RXNQRZ³HUURU´$QVZHUVDUHDWWKHERWWRPRIWKHQH[WSDJH     (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 $ONTBESURPRISEDIFYOUlNDSOMETHINGLIKE THISONTHEEXAMEXCEPTINTHEREALEXAMITLL LOOKUGLIER 3TUDYTHETHREECLASSESONTHEPAGEAND THESERVLETCODEONTHEOPPOSITEPAGETHEN CONSTRUCTTHECODEMAGNETSTOMAKETHE%, THATLLPRODUCETHERESPONSESHOWNINTHE BROWSER4URNTHEPAGEFORTHEANSWERSBUT NOTUNTILYOU$/4()3ESPECIALLYIFYOURE GOINGTOTAKETHEEXAM SDFNDJHIRR SXEOLFFODVV'RJ^ SULYDWH6WULQJQDPH SULYDWH7R\>@WR\V SXEOLFYRLGVHW1DPH6WULQJQDPH^ WKLVQDPH QDPH ` SXEOLF6WULQJJHW1DPH^ UHWXUQQDPH ` SXEOLFYRLGVHW7R\V7R\>@WR\V^ WKLVWR\V WR\V ` SXEOLF7R\>@JHW7R\V^ UHWXUQWR\V ` ` IRR'RJ SDFNDJHIRR SXEOLFFODVV3HUVRQ^ SULYDWH'RJGRJ SULYDWH6WULQJQDPH SXEOLFYRLGVHW'RJ'RJGRJ^ WKLVGRJ GRJ ` SXEOLF'RJJHW'RJ^ UHWXUQGRJ ` SXEOLFYRLGVHW1DPH6WULQJQDPH^ WKLVQDPH QDPH ` SXEOLF6WULQJJHW1DPH^ UHWXUQQDPH ` ` IRR3HUVRQ SDFNDJHIRR SXEOLFFODVV7R\^ SULYDWH6WULQJQDPH SXEOLFYRLGVHW1DPH6WULQJQDPH^ WKLVQDPH QDPH ` SXEOLF6WULQJJHW1DPH^ UHWXUQQDPH ` ` IRR7R\ &RGH0DJQHWV $QVZHUVWR6KDUSHQRQSUHYLRXVSDJH7DKLWL%7)U RX)URX)URX)URX ELJH[HUFLVHRQ(/ 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 \RXDUHKHUH  IRR3HUVRQS QHZIRR3HUVRQ SVHW1DPH³/HHOX´ IRR'RJG QHZIRR'RJ GVHW1DPH³&O\GH´ IRR7R\W QHZIRR7R\ WVHW1DPH³VWLFN´ IRR7R\W QHZIRR7R\ WVHW1DPH³QHLJKERU¶VFDW´ IRR7R\W QHZIRR7R\ WVHW1DPH³%DUELHGROOKHDG´ GVHW7R\VQHZIRR7R\>@^WWW` SVHW'RJG UHTXHVWVHW$WWULEXWH³SHUVRQ´S 6HUYOHWFRGH KWWSORFDOKRVWWHVW-637HVWHUGR /HHOX¶VGRJ&O\GH¶VWR\VDUHVWLFN QHLJKERU¶VFDWDQGD%DUELHGROO KHDG &RPSRVHWKH(/IRUWKLVRXWSXW ¶V ^SHUVRQQDPH` GRJ ^SHUVRQGRJWR\V ^SHUVRQGRJQDPH` WR\VDUH ¶V ^SHUVRQGRJ ` >@ QDPH WR\V>@ QDPH ` DQGD ^SHUVRQ GRJ WR\V >@ QDPH  ` QDPH WR\V WR\V WR\V   ^SHUVRQGRJWR\VQDPH` ^SHUVRQGRJWR\VQDPH` WR\V ^SHUVRQGRJWR\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 IRR3HUVRQS QHZIRR(PSOR\HH SVHW1DPH³/HHOX´ IRR'RJG QHZIRR'RJ GVHW1DPH³&O\GH´ IRR7R\W QHZIRR7R\ WVHW1DPH³VWLFN´ IRR7R\W QHZIRR7R\ WVHW1DPH³QHLJKERU¶VFDW´ IRR7R\W QHZIRR7R\ WVHW1DPH³%DUELHGROOKHDG´ GVHW7R\VQHZIRR7R\>@^WWW` SVHW'RJG UHTXHVWVHW$WWULEXWH³SHUVRQ´S 6HUYOHWFRGH KWWSORFDOKRVWWHVW-637HVWHUGR /HHOX¶VGRJ&O\GH¶VWR\VDUH VWLFNQHLJKERU¶VFDWDQGD %DUELHGROOKHDG &RPSRVHWKH(/IRUWKLVRXWSXW ¶V ^SHUVRQQDPH`¶VGRJ^SHUVRQGRJQDPH`¶VWR\VDUH^SHUVRQGRJWR\V>@ QDPH`^SHUVRQGRJWR\V>@QDPH`DQGD^SHUVRQGRJWR\V>@QDPH` ^SHUVRQQDPH` GRJ ^SHUVRQGRJWR\V ^SHUVRQGRJQDPH` WR\VDUH¶V ^SHUVRQGRJ ` >@ QDPH WR\V>@ QDPH ` DQGD ^SHUVRQ GRJ WR\V >@ QDPH  ` &RGH0DJQHWV $QVZHUV >@ >@ WR\V>³QDPH´@ ^SHUVRQGRJWR\V>³QDPH´@ WR\V ^SHUVRQGRJWR\VQDPH` ^SHUVRQGRJWR\VQDPH`   WR\V WR\V WR\V QDPH H[HUFLVHDQVZHUV 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 \RXDUHKHUH  <PM-4QUXTQKQ\WJRMK\[ 2EMEMBER%,HASSOMEIMPLICITOBJECTS"UTTHESE ARENOTTHESAMEASTHE*30IMPLICITOBJECTSEXCEPT FORONEPAGE#ONTEXT(ERESAQUICKLISTWELLLOOK ATSOMEOFTHEMINMOREDETAILONTHENEXTFEWPAGES 9OULLNOTICETHATALLBUTONEPAGE#ONTEXTAGAINARE SIMPLE-APSNAMEVALUEPAIRS 5HPHPEHUWKDWP\+70/IRUP DFWLRQJRHVVWUDLJKWWRWKH -63LVWKHUHDZD\,FDQXVHWKH UHTXHVWSDUDPHWHUVMXVWXVLQJ(/" 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 0IECEOFCAKE4HEPARAMIMPLICITOBJECTISlNEWHENYOUKNOWYOUHAVEONLY ONEPARAMETERFORTHATPARTICULARPARAMETERNAME5SEPARAM6ALUESWHENYOU MIGHTHAVEMORETHANONEPARAMETERVALUEFORAGIVENPARAMETERNAME ,QWKH+70/IRUP IRUPDFWLRQ ´7HVW%HDQMVS´! 1DPHLQSXWW\SH ´WH[W´QDPH ´QDPH´! ,'LQSXWW\SH ´WH[W´QDPH ´HPS,'´!  )LUVWIRRGLQSXWW\SH ´WH[W´QDPH ´IRRG´! 6HFRQGIRRGLQSXWW\SH ´WH[W´QDPH ´IRRG´!  LQSXWW\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 5HTXHVWSDUDPQDPHLV^SDUDPQDPH`EU! 5HTXHVWSDUDPHPS,'LV^SDUDPHPS,'`EU! 5HTXHVWSDUDPIRRGLV^SDUDPIRRG`EU! )LUVWIRRGUHTXHVWSDUDP^SDUDP9DOXHVIRRG>@`EU! 6HFRQGIRRGUHTXHVWSDUDP^SDUDP9DOXHVIRRG>@`EU! 5HTXHVWSDUDPQDPH^SDUDP9DOXHVQDPH>@` KWWSORFDOKRVWWHVW-637HVWHUGR 5HTXHVWSDUDPQDPHLV)OXII\ 5HTXHVWSDUDPHPS,'LV 5HTXHVWSDUDPIRRGLV6XVKL )LUVWIRRGUHTXHVWSDUDP6XVKL 6HFRQGIRRGUHTXHVWSDUDP0DFDURQL &KHHVH 5HTXHVWSDUDPQDPH)OXII\ KWWSORFDOKRVWWHVW-637HVW%HDQMVS 1DPH ,' )LUVWIRRG 6HFRQGIRRG )OXII\  6XVKL 0DFDURQL&KHHVH ,QWKH-63 ,QWKHFOLHQW·VEURZVHUFOLHQWÀOOVLQ WKHIRUPDQGKLWVWKHVXEPLWEXWWRQ 7KHUHVSRQVH 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. SDUDPDQGSDUDP9DOXHV 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 \RXDUHKHUH  ?PI\QNaW]_IV\UWZMQVNWZUI\QWVNZWU\PMZMY]M[\' 7HATIFYOUWANTSAYTHESERVERHOSTINFORMATIONTHATCOMESWITHTHEhHOSTvHEADERIN THEREQUEST)FYOULOOKINTHE(TTP3ERVLET2EQUEST!0)YOUCANSEEAGET(EADER3TRING METHOD7EKNOWTHATIFWEPASShHOSTvTOTHEGET(EADERMETHODWELLGETBACK SOMETHINGLIKEhLOCALHOSTvBECAUSETHATSWHERETHEWEBSERVERIS :HNQRZZHFDQGRLWZLWK VFULSWLQJ +RVWLV UHTXHVWJHW+HDGHU³KRVW´! %XWZLWK(/ZH¶YHJRWWKHKHDGHULPSOLFLWREMHFW +RVWLV^KHDGHU>³KRVW´@`  +RVWLV^KHDGHUKRVW` 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.) *HWWLQJWKH´KRVWµKHDGHU :HNQRZZHFDQGRLWZLWK VFULSWLQJ 0HWKRGLV UHTXHVWJHW0HWKRG! %XWZLWK(/ WKLV ZLOO127ZRUN 0HWKRGLV^UHTXHVWPHWKRG` *HWWLQJWKH+773UHTXHVWPHWKRG 5HOH4HISISALITTLETRICKIERTHERESAMETHODINTHE (TTP3ERVLET2EQUEST!0)FORGET-ETHODTHATRETURNS'%40/34ETC "UTHOWDO)GETITUSING%, NO! NO! NO! There IS no implicit request object! $QG WKLV ZLOO127ZRUN 0HWKRGLV^UHTXHVW6FRSHPHWKRG` NO! NO! NO! There IS an implicit requestScope, but itÕs NOT the request object itself. &DQ\RXÀJXUHRXWKRZWRGRLW" +LQWORRNDWWKHRWKHULPSOLFLWREMHFWV 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 <PMZMY]M[\;KWXMQ[67<\PMZMY]M[\WJRMK\ 4HEIMPLICITREQUEST3COPEISJUSTA-APOFTHEREQUESTSCOPEATTRIBUTES NOTTHEREQUESTOBJECTITSELF7HATYOUWANTTHE(440METHODISA PROPERTYOFTHEREQUESTOBJECTNOTANATTRIBUTEATREQUESTSCOPE)NOTHER WORDSYOUWANTSOMETHINGTHATCOMESFROMCALLINGAGETTERMETHODON THEREQUESTOBJECTIFWETREATTHEREQUESTOBJECTLIKEABEAN "UTTHEREISNOREQUESTIMPLICITOBJECTONLYREQUEST3COPE7HATTODO 9OUNEEDSOMETHINGELSE 8VHUHTXHVW6FRSHWRJHWUHTXHVW $775,%87(6QRWUHTXHVW3523(57,(6 )RUUHTXHVWSURSHUWLHV\RXQHHGWRJR WKURXJKSDJH&RQWH[W 0HWKRGLV^SDJH&RQWH[WUHTXHVWPHWKRG` 8VHSDJH&RQWH[WWRJHWWRHYHU\WKLQJHOVH SDJH&RQWH[W KDVD UHTXHVW SURSHUW\ UHTXHVW KDVD PHWKRG SURSHUW\  ,W¶VVRHDV\WRWKLQNWKDWVD\DSSOLFDWLRQ6FRSHLVDUHIHUHQFHWR6HUY OHW&RQWH[WVLQFHWKDW¶VZKHUHDSSOLFDWLRQVFRSHGDWWULEXWHVDUHERXQG %XWMXVWDVZLWKUHTXHVW6FRSHDQGWKHUHTXHVWREMHFWWKHVFRSH0DSIRU DSSOLFDWLRQVFRSHGDWWULEXWHVLVMXVWWKDW²D0DSRIDWWULEXWHVDQGQRWK LQJPRUH<RXFDQ¶WWUHDWLWOLNHD6HUYOHW&RQWH[WVRGRQ¶WH[SHFWWRJHW 6HUYOHW&RQWH[WSURSHUWLHVEDFNIURPWKHDSSOLFDWLRQ6FRSHLPSOLFLWREMHFW 'RQ·WFRQIXVHWKH0DS VFRSH REMHFWVZLWKWKH REMHFWVWRZKLFKWKHDWWULEXWHVDUHERXQG VFRSHPDSVDUH127WKHUHDOREMHFW 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 \RXDUHKHUH  ;KWXMQUXTQKQ\WJRMK\[KIV[I^MaW] )FALLYOUNEEDISTOPRINTTHENAMEOFAPERSONANDYOUREALLY DONTCAREWHATSCOPETHEPERSONISINORYOUDOCAREBUT YOUKNOWTHERESONLYONEPERSONOUTOFALLFOURSCOPESYOU JUSTUSE /RIFYOUREWORRIEDABOUTAPOTENTIALNAMINGCONmICTYOU CANBEEXPLICITABOUTWHICHPERSONYOUWANT ^UHTXHVW6FRSHSHUVRQQDPH` "UTISTHEREANOTHERREASONYOUMIGHTHAVETOPREFACETHE ATTRIBUTEWITHTHEIMPLICITSCOPEOBJECT/THERTHANTO CONTROLSCOPING 4HINKABOUTTHISSCENARIOIFYOUHAVEANAMETHATSNOT INQUOTESINBRACKETS;=THATMEANSIT-534ADHERETO *AVANAMINGRULESRIGHT(EREWERE/+BECAUSEPERSON ISAPERFECTLYLEGAL*AVAVARIABLENAME"UTTHATSBECAUSE SOMEWHERESOMEONESAID UHTXHVWVHW$WWULEXWH³SHUVRQ´S "UTANATTRIBUTENAMEISA3TRING 3TRINGSDONTFOLLOW*AVAVARIABLENAMERULES 4HATMEANSSOMEONE COULD SAY UHTXHVWVHW$WWULEXWH³IRRSHUVRQ´S !NDTHENYOUDBEINTROUBLEBECAUSE4()3WONTWORK ^IRRSHUVRQQDPH` "UTYOULLBESOTHANKFULFORSCOPEOBJECTSBECAUSEUSINGA SCOPEOBJECTLETSYOUSWITCHTOTHE;=OPERATORTHATCANTAKE 3TRINGNAMESTHATDONTCONFORMTO*AVANAMINGRULES ,I(/ORRNVWKURXJKDOOWKH VFRSHVDQ\ZD\ZK\ZRXOG ,HYHUXVHRQHRIWKHVFRSH LPSOLFLWREMHFWV"7KHRQO\WKLQJ, FDQWKLQNRILVDQDPLQJFRQÁLFW EXW,ZRQGHULIWKHUHPLJKW EHDQRWKHUUHDVRQ ^SHUVRQQDPH` ^ UHTXHVW6FRSH>³IRRSHUVRQ´@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 ` SXEOLF6WULQJJHW1DPH^ UHWXUQQDPH ` ` IRR7R &RGH0DJQHWV $QVZHUVWR6KDUSHQRQSUHYLRXVSDJH7DKLWL%7)U RX)URX)URX)URX ELJH[HUFLVHRQ(/ Chapter 8. Script-free pages Chapter 8. Script-free pages Head First Servlets and JSP By Bert

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

Từ khóa liên quan

Mục lục

  • Using JSTL

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan