Given the JSP code: <% request.setAttribute("foo", "bar"); %>and the Classic tag handler code: 5. public int doStartTag() throws JspException { 6. // insert code here 7. // return int 8. } Assume there are no other "foo" attributes in the web application

题目

Given the JSP code: <% request.setAttribute("foo", "bar"); %>and the Classic tag handler code: 5. public int doStartTag() throws JspException { 6. // insert code here 7. // return int 8. } Assume there are no other "foo" attributes in the web application. Which invocation on the pageContextobject,inserted at line 6,assigns "bar" to the variable x?()

  • A、String x = (String) pageContext.getAttribute("foo")
  • B、String x = (String) pageContext.getRequestScope("foo")
  • C、It is NOT possible to access the pageContext object from within doStartTag
  • D、String x = (String) pageContext.getRequest().getAttribute("foo")
  • E、String x = (String) pageContext.getAttribute("foo", PageContext.ANY_SCOPE)

相似考题
更多“Given the JSP co”相关问题
  • 第1题:

    Given:11.<servlet>12.<servlet-name>catalog</servlet-name>13.<jsp-file>/catalogTemplate.jsp</jsp-file>14.<load-on-startup>10</load-on-startup>15.</servlet>Whichtwoaretrue?()

    A.Line13isnotvalidforaservletdeclaration.

    B.Line14isnotvalidforaservletdeclaration.

    C.Oneinstanceoftheservletwillbeloadedatstartup.

    D.Teninstancesoftheservletwillbeloadedatstartup.

    E.Theservletwillbereferencedbythenamecataloginmappings.


    参考答案:C, E

  • 第2题:

    在J2EE中,在aa.jsp中有行代码:  <%><%  request.setAttribute("Co.","jb-aptech");  %>  在bb.jsp中有行代码: <%  out.println((String)request.getAttribute("Co."));  %>    <%>   为了使得在bb.jsp中的如上代码可以显示“jb-aptech”,可以使用()方法。

    • A、在aa.jsp中使用<form method=post action="bb.jsp">把请求提交到bb.jsp 
    • B、在aa.jsp中使用<jsp:forward file="bb.jsp" />把页面重定向到bb.jsp  
    • C、在aa.jsp中使用<%  response.sendRedirect("bb.jsp");  %>把页面重定向到bb.jsp 
    • D、在aa.jsp中使用<%@ include file="bb.jsp" %>包含页面bb.jsp  
    • E、在aa.jsp中使用<% config.getServletContext().getRequestDispatcher("/bb.jsp").forward(request,response); %>把页面重定向到bb.jsp

    正确答案:D,E

  • 第3题:

    Given the element from the web application deployment descriptor: /main/page1.jsp true and given that /main/page1.jsp contains: <% int i = 12; %> <%= i %>  What is the result?()

    • A、<b></b>
    • B、<b>12</b>
    • C、The JSP fails to execute.
    • D、<% int i = 12 %><b><%= i %></b>

    正确答案:C

  • 第4题:

    JSP标准动作不包括()。 

    • A、<jsp:forward /> 
    • B、<jsp:forEach /> 
    • C、<jsp:useBean /> 
    • D、<jsp:setProperry /> 

    正确答案:B

  • 第5题:

    You are building your own layout mechanism by including dynamic content for the page’s header and footersections. The footer is always static, but the header generates the  tag that requires the page name tobe specified dynamically when the header is imported. Which JSP code snippet performs the import of theheader content?() <title>

    • A、<jsp:include page=’/WEB-INF/jsp/header.jsp’><jsp:param name=’pageName’ value=’Welcome Page’ /> </jsp:include>
    • B、<jsp:import page=’/WEB-INF/jsp/header.jsp’><jsp:param name=’pageName’ value=’Welcome Page’ /> </jsp:import>
    • C、<jsp:include page=’/WEB-INF/jsp/header.jsp’><jsp:attribute name=’pageName’ value=’Welcome Page’ /> . </jsp:include>
    • D、<jsp:import page=’/WEB-INF/jsp/header.jsp’>. <jsp:attribute name=’pageName’ value=’Welcome Page’ /> . </jsp:import>

    正确答案:A

  • 第6题:

    Which two are valid and equivalent?()

    • A、<%! int i; %>
    • B、<%= int i; %>
    • C、<jsp:expr>int i;</jsp:expr>
    • D、<jsp:scriptlet>int i;</jsp:scriptlet>
    • E、<jsp:declaration>int i;</jsp:declaration>

    正确答案:A,E

  • 第7题:

    Given the JSP code: 10. 11. 12. 13.Hello, ${customer.title} ${customer.lastName}, welcome 14.to Squeaky Beans, Inc. 15.16.  Which three types of JSP code are used?()

    • A、Java code
    • B、Template text
    • C、Scripting code
    • D、Standard action
    • E、Expression language

    正确答案:B,D,E

  • 第8题:

    单选题
    For debugging purposes, you need to record how many times a given JSP is invoked before the user’ssession has been created. The JSP’s destroy method stores this information to a database. Which JSPcode snippet keeps track of this count for the lifetime of the JSP page?()
    A

    <%! int count = 0; %><% if ( request.getSession(false) == null ) count++; %>

    B

    <%@ int count = 0; %>. <% if ( request.getSession(false) == null ) count++; %>

    C

    <% int count = 0;. if ( request.getSession(false) == null ) count++; %>

    D

    <%@ int count = 0;. if ( request.getSession(false) == null ) count++; %>

    E

    <%! int count = 0;. if ( request.getSession(false) == null ) count++; %>


    正确答案: E
    解析: 暂无解析

  • 第9题:

    单选题
    Given the element from the web application deployment descriptor: /main/page1.jsp true and given that /main/page1.jsp contains:   What is the result?()
    A

    <b></b>

    B

    <b>12</b>

    C

    The JSP fails to execute.

    D

    <% int i = 12 %><b><%= i %></b>


    正确答案: D
    解析: 暂无解析

  • 第10题:

    单选题
    Given a JSP error page, which implicit object refers to the uncaught Throwable that resulted in th epage being invoked?()
    A

     Error

    B

     Exception

    C

     Throwable

    D

     Request error

    E

     Request exception


    正确答案: B
    解析: 暂无解析

  • 第11题:

    单选题
    Given that login.getName() returns a java.lang.String value and given the JSP code:  Welcome Which is equivalent?()
    A

    <%> Welcome <% out.print(login.getName()); %> 

    B

     Welcome <% writer.print(login.getName()); %> 

    C

     Welcome <% response.out.print(login.getName()); %>

    D

     Welcome <% response.writer.print(login.getName()); %> 

    E

     Welcome <% response.getOutputStream().write(login.getName()); %>


    正确答案: C
    解析: 暂无解析

  • 第12题:

    单选题
    Given this fragment from a Java EE deployment descriptor: 341. 342.java.lang.Throwable  343./mainError.jsp 344. 345. 346.java.lang.ClassCastException  347./castError.jsp 348. If the web application associated with the fragment above throws a ClassCastException.Which statement is true?()
    A

    The deployment descriptor is invalid.

    B

    The container invokes mainError.jsp.

    C

    The container invokes castError.jsp.

    D

    Neither mainError.jsp nor castError.jsp is invoked.


    正确答案: C
    解析: 暂无解析

  • 第13题:

    WhichJSPstandardactioncanbeusedtoimportcontentfromaresourcecalledfoo.jsp?()

    A.<jsp:importfile=’foo.jsp’/>

    B.<jsp:importpage=’foo.jsp’/>

    C.<jsp:includepage=’foo.jsp’/>

    D.<jsp:includefile=’foo.jsp’/>


    参考答案:C

  • 第14题:

    Given a JSP error page, which implicit object refers to the uncaught Throwable that resulted in th epage being invoked?()

    • A、 Error
    • B、 Exception
    • C、 Throwable
    • D、 Request error
    • E、 Request exception

    正确答案:B

  • 第15题:

    Which JSP standard action can be used to import content from a resource called foo.jsp?()

    • A、<jsp:import file=’foo.jsp’ />
    • B、<jsp:import page=’foo.jsp’ />
    • C、<jsp:include page=’foo.jsp’ />
    • D、<jsp:include file=’foo.jsp’ />

    正确答案:C

  • 第16题:

    JSP页面包括以下哪些元素?()

    • A、JSP指令
    • B、JSP Action
    • C、JSP脚本
    • D、JSP控件

    正确答案:A,B,C

  • 第17题:

    Given this fragment from a Java EE deployment descriptor: 341. 342.java.lang.Throwable  343./mainError.jsp 344. 345. 346.java.lang.ClassCastException  347./castError.jsp 348. If the web application associated with the fragment above throws a ClassCastException.Which statement is true?()

    • A、The deployment descriptor is invalid.
    • B、The container invokes mainError.jsp.
    • C、The container invokes castError.jsp.
    • D、Neither mainError.jsp nor castError.jsp is invoked.

    正确答案:C

  • 第18题:

    A JSP page needs to set the property of a given JavaBean to a value that is calculated with the JSP page. Which three jsp:setProperty attributes must be used to perform this initialization?()

    • A、Id
    • B、Val
    • C、Name
    • D、Param
    • E、Value
    • F、Property

    正确答案:C,E,F

  • 第19题:

    多选题
    Given the JSP code: 10. 11. 12. 13.Hello, ${customer.title} ${customer.lastName}, welcome 14.to Squeaky Beans, Inc. 15.16.  Which three types of JSP code are used?()
    A

    Java code

    B

    Template text

    C

    Scripting code

    D

    Standard action

    E

    Expression language


    正确答案: A,D
    解析: 暂无解析

  • 第20题:

    多选题
    Given the JSP code: 10. 11. 12. 13.Hello, ${customer.title} ${customer.lastName}, welcome 14.to Squeaky Beans, Inc. 15.16.  Which three types of JSP code are used?()
    A

    Java code

    B

    Template text

    C

    Scripting code

    D

    Standard action

    E

    Expression language


    正确答案: A,C
    解析: 暂无解析

  • 第21题:

    单选题
    A session-scoped attribute, product, is stored by a servlet. That servlet then forwards to a JSP page. This attribute holds an instance of the com.Company.   Product class with a name property of “The Matrix” and price property of 39.95. Given the JSP page code snippet: What is the response output of this JSP page code snippet? ()
    A

     Default costs 0.0

    B

     Default costs 49.95

    C

     Default costs 39.95

    D

     The Matrix costs 0.0

    E

     The Matrix costs 49.95

    F

     The Matrix costs 39.95


    正确答案: C
    解析: 暂无解析

  • 第22题:

    单选题
    Given the element from the web application deployment descriptor: /main/page1.jsp true and given that /main/page1.jsp contains:   What is the result?()
    A

    <b></b>

    B

    <b>12</b>

    C

    The JSP fails to execute.

    D

    <% int i = 12 %><b><%= i %></b>


    正确答案: B
    解析: 暂无解析

  • 第23题:

    多选题
    A JSP page needs to set the property of a given JavaBean to a value that is calculated with the JSP page. Which three jsp:setProperty attributes must be used to perform this initialization?()
    A

    Id

    B

    Val

    C

    Name

    D

    Param

    E

    Value

    F

    Property


    正确答案: C,B
    解析: 暂无解析

  • 第24题:

    单选题
    Given this fragment from a Java EE deployment descriptor: 341. 342.java.lang.Throwable  343./mainError.jsp 344. 345. 346.java.lang.ClassCastException  347./castError.jsp 348. If the web application associated with the fragment above throws a ClassCastException.Which statement is true?()
    A

    The deployment descriptor is invalid.

    B

    The container invokes mainError.jsp.

    C

    The container invokes castError.jsp.

    D

    Neither mainError.jsp nor castError.jsp is invoked.


    正确答案: C
    解析: 暂无解析