YouarebuildingawebapplicationthatwillbeusedthroughouttheEuropeanUnion;therefore,ithas significantinternationalizationrequirements.Youhavebeentaskedtocreateacustomtagthatgeneratesamessageusingthejava.text.MessageFormatclass.ThetagwilltaketheresourceKeyattributeanda variablenumberofargumentattributeswiththeformat,arg.Hereisanexampleuseofthistaganditsoutput:generates:Thedisk"MyDisk"contains1247file(s).
WhichSimpletagclassdefinitionaccomplishesthisgoalofhandlingavariable numberoftagattributes?()
第1题
sictaghandlercode:5.publicintdoStartTag()throwsJspException{6.//insertcodehere7.//returnint8.}Assumetherearenoother"foo"attributesinthewebapplication.WhichinvocationonthepageContextobject,insertedatline6,assigns"bar"tothevariablex?()
A.Stringx=(String)pageContext.getAttribute("foo")
B.Stringx=(String)pageContext.getRequestScope("foo")
C.ItisNOTpossibletoaccessthepageContextobjectfromwithindoStartTag
D.Stringx=(String)pageContext.getRequest().getAttribute("foo")
E.Stringx=(String)pageContext.getAttribute("foo",PageContext.ANY_SCOPE)
第2题
;sl:shoppingList>12.<sl:itemname="Bread"/>13.<sl:itemname="Milk"/>14.<sl:itemname="Eggs"/>15.</sl:shoppingList>Thetaghandlerforsl:shoppingListisShoppingListTagandthetaghandlerforsl:itemisItemSimpleTag.ShoppingListTagextendsBodyTagSupportandItemSimpleTagextendsSimpleTagSupport.Whichistrue?()
A.ItemSimpleTagcanfindtheenclosinginstanceofShoppingListTagbycallinggetParent()andcastingtheresulttoShoppingListTag.
B.ShoppingListTagcanfindthechildinstancesofItemSimpleTagbycallingsuper.getChildren()andcastingeachtoanItemSimpleTag.
C.ItisimpossibleforItemSimpleTagandShoppingListTagtofindeachotherinataghierarchybecauseoneisaSimpletagandtheotherisaClassictag.
D.ShoppingListTagcanfindthechildinstancesofItemSimpleTagbycallinggetChildren()onthePageContextandcastingeachtoanItemSimpleTag.
E.ItemSimpleTagcanfindtheenclosinginstanceofShoppingListTagbycallingfindAncestorWithClass()onthePageContextandcastingtheresulttoShoppingListTag.
第3题
tainer.ServletAneedstosharedatawithservletBandthatdatamustnotbevisibletootherservletsinA’swebapplication.InwhichobjectcanthedatathatAshareswithBbestored?()
A.HttpSession
B.ServletConfig
C.ServletContext
D.HttpServletRequest
E.HttpServletResponse
第4题
tor.AnAdapterlisanon-abstract,non-finalclasswithoutazeroargumentconstructor,butwithaconstructorthattakesoneintargument.Whichtwoconstructananonymousinnerclass()?
A.AnAdapter1aa=newAnAdapter1(){}
B.AnAdapter0aa=newAnAdapter0(){}
C.AnAdapter0aa=newAnAdapter0(5){}
D.AnAdapter1aa=newAnAdapter1(5){}
E.AnInterfaceai=newAnlnterface(5)){}
第5题
A.IncludealistenerdirectiveinaJSPpage
B.configurealistenerintheTLDfileusingthe
C.Includea
D.configurealistenerintheapplicationdeploymentdescriptor,usingthe
E.IncludeaclassimplementingServletContextListeneraspartofthewebapplicationdeploymen
第6题
A.Yourfilterclassmustimplementaninitmethodandadestroymethod.
B.Yourfilterclassmustalsoimplementjavax.servlet.FilterChain.
C.Whenyourfilterchainstothenextfilter,itshouldpassthesameargumentsitreceivedinitsdoFiltermethod.
D.Themethodthatyourfilterinvokesontheobjectitreceivedthatimplementsjavax.servlet.FilterChaincaninvokeeitheranotherfilteroraservlet.
E.YourfilterclassmustimplementadoFiltermethodthattakes,amongotherthings,anHTTPServletRequestobjectandanHTTPServletResponseobject.
第8题
A.AnexceptionisthrownatruntimebySourceServlet.
B.AnexceptionisthrownatruntimebyDestinationServlet.
C.Only"hellofromdest"appearsintheresponseoutputstream.
D.Both"hellofromsource"and"hellofromdest"appearintheresponseoutputstream.
第9题
ossmultiplerequestsfromthatuser,fromthesamebrowserinstance.Whichtwoprovidethiscapability fromwithinataghandler?()
A.pageContext.setAttribute("name",theValue)
B.pageContext.setAttribute("name",getSession())
C.pageContext.getRequest().setAttribute("name",theValue)
D.pageContext.getSession().setAttribute("name",theValue)
E.pageContext.setAttribute("name",theValue,PageContext.PAGE_SCOPE)
F.pageContext.setAttribute("name",theValue,PageContext.SESSION_SCOPE)
第10题
ce(HttpServletRequestrequest,13.HttpServletResponseresponse)14.throwsServletException,IOException{15.HttpSessionsession=request.getSession();16.session.setAttribute("myAttribute","myAttributeValue");17.session.invalidate();18.response.getWriter().println("value="+19.session.getAttribute("myAttribute"));20.}21.}WhatistheresultwhenarequestissenttoMyServlet?()
A.AnIllegalStateExceptionisthrownatruntime.
B.AnInvalidSessionExceptionisthrownatruntime.
C.Thestring"value=null"appearsintheresponsestream.
D.Thestring"value=myAttributeValue"appearsintheresponsestream.
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!