SCDCD(310-081)

单选题Assume a tag handler extends TagSupport. Which is used within the tag handler to get an attribute “foo” that is in the application scope?()ApageContext.getAttribute(“foo”);BgetPageContext().getAttribute(“foo”);CpageContext.getApplicationScope(“foo”);Dp

题目
单选题
Assume a tag handler extends TagSupport. Which is used within the tag handler to get an attribute “foo” that is in the application scope?()
A

 pageContext.getAttribute(“foo”);

B

 getPageContext().getAttribute(“foo”);

C

 pageContext.getApplicationScope(“foo”);

D

 pageContext.getAttribute(“foo”,pageContext.APPLICATION_SCOPE).getAttribute(“foo”);

E

 getPageContext().getScope(pageContext.APPLICATION_SCOPE).getAttribute(“foo”);

参考答案和解析
正确答案: C
解析: 暂无解析
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

GiventheJSPcode:<%request.setAttribute("foo","bar");%>andtheClassictaghandlercode: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)


参考答案:D

第2题:

A custom JSP tag must be able to support an arbitrary number of attributes whose names are unknown when the tag class is designed.  Which two are true? ()

  • A、 A  element in the echo tag LTD must have the value JSP
  • B、 The echo tag handler must define the setAttribute (String key, String value) method
  • C、 The true element must appear in the echo tag TLD
  • D、 The class implementing the echo tag handler must implement the javax.sevlet.jsp.tagext.IterationTag interface
  • E、 The class implementing the echo tag handler must implement the javax.sevlet.jsp.tagext.DynamicAttributes interface

正确答案:C,E

第3题:

AssumeataghandlerextendsTagSupport.Whichisusedwithinthetaghandlertogetanattribute“foo”thatisintheapplicationscope?()

A.pageContext.getAttribute(“foo”);

B.getPageContext().getAttribute(“foo”);

C.pageContext.getApplicationScope(“foo”);

D.pageContext.getAttribute(“foo”,pageContext.APPLICATION_SCOPE).getAttribute(“foo”);

E.getPageContext().getScope(pageContext.APPLICATION_SCOPE).getAttribute(“foo”);


参考答案:D

第4题:

Assume the tag handler for a st:simple tag extends Simple Tag Support. In what way can scriptlet code beused in the body of st:simple?()

  • A、Set the body content type to JSP in the TLD
  • B、Scriptlet code is NOT legal in the body of st:simple.
  • C、Add scripting-enabled="true" to the start tag for the st:simple element
  • D、Add a pass-through Classic tag with a body content type of JSP to the body of st:simple, and place the scriptlet code in the body of that tag

正确答案:B

第5题:

Given: 6. 7.<%="processing" %> 8. and a custom tag handler for foo which extends TagSupport. Which two are true about thetag handler referenced by foo?()

  • A、The doStartTag method is called once.
  • B、The doAfterBody method is NOT called.
  • C、The EVAL_PAGE constant is a valid return value for the doEndTag method.
  • D、The SKIP_PAGE constant is a valid return value for the doStartTag method.
  • E、The EVAL_BODY_BUFFERED constant is a valid return value for the doStartTag method.

正确答案:A,C

第6题:

Given: 3.public class MyTagHandler extends TagSupport { 4.public int doStartTag() { 5.// insert code here 6.// return an int 7.} 8.// more code here ... 18.} There is a single attribute foo in the session scope. Which three code fragments,inserted independently atline 5,return the value of the attribute?()

  • A、Object o = pageContext.getAttribute("foo");
  • B、Object o = pageContext.findAttribute("foo");
  • C、Object o = pageContext.getAttribute("foo",PageContext.SESSION_SCOPE);
  • D、HttpSession s = pageContext.getSession();Object o = s.getAttribute("foo");

正确答案:B,C,D

第7题:

class One {  void foo() {}  }  class Two extends One {   //insert method here  }  Which three methods, inserted individually at line 14, will correctly complete class Two?()

  • A、 int foo() { /* more code here */ }
  • B、 void foo() { /* more code here */ }
  • C、 public void foo() { /* more code here */ }
  • D、 private void foo() { /* more code here */ }
  • E、 protected void foo() { /* more code here */ }

正确答案:B,C,E

第8题:

Given:3.publicclassMyTagHandlerextendsTagSupport{4.publicintdoStartTag(){5.//insertcodehere6.//returnanint7.}8.//morecodehere...18.}Thereisasingleattributefoointhesessionscope.Whichthreecodefragments,insertedindependentlyatline5,returnthevalueoftheattribute?()

A.Objecto=pageContext.getAttribute("foo");

B.Objecto=pageContext.findAttribute("foo");

C.Objecto=pageContext.getAttribute("foo",PageContext.SESSION_SCOPE);

D.HttpSessions=pageContext.getSession();Objecto=s.getAttribute("foo");


参考答案:B, C, D

第9题:

Assume a tag handler extends TagSupport. Which is used within the tag handler to get an attribute “foo” that is in the application scope?()

  • A、 pageContext.getAttribute(“foo”);
  • B、 getPageContext().getAttribute(“foo”);
  • C、 pageContext.getApplicationScope(“foo”);
  • D、 pageContext.getAttribute(“foo”,pageContext.APPLICATION_SCOPE).getAttribute(“foo”);
  • E、 getPageContext().getScope(pageContext.APPLICATION_SCOPE).getAttribute(“foo”);

正确答案:D

第10题:

class One {   public One foo() { return this; }  }  class Two extends One {  public One foo() { return this; }  }  class Three extends Two {   // insert method here  }  Which two methods, inserted individually, correctly complete the Three class?()

  • A、 public void foo() { }
  • B、 public int foo() { return 3; }
  • C、 public Two foo() { return this; }
  • D、 public One foo() { return this; }
  • E、 public Object foo() { return this; }

正确答案:C,D

更多相关问题