Java认证考试

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)
如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

Youarebuildingyourownlayoutmechanismbyincludingdynamiccontentforthepage’sheaderandfootersections.Thefooterisalwaysstatic,buttheheadergeneratesthe<title>tagthatrequiresthepagenametobespecifieddynamicallywhentheheaderisimported.WhichJSPcodesnippetperformstheimportoftheheadercontent?()

A.<jsp:includepage=’/WEB-INF/jsp/header.jsp’><jsp:paramname=’pageName’value=’WelcomePage’/></jsp:include>

B.<jsp:importpage=’/WEB-INF/jsp/header.jsp’><jsp:paramname=’pageName’value=’WelcomePage’/></jsp:import>

C.<jsp:includepage=’/WEB-INF/jsp/header.jsp’><jsp:attributename=’pageName’value=’WelcomePage’/>.</jsp:include>

D.<jsp:importpage=’/WEB-INF/jsp/header.jsp’>.<jsp:attributename=’pageName’value=’WelcomePage’/>.</jsp:import>


参考答案:A

第2题:

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

第3题:

在J2EE中,在aa.jsp中有行代码:<%request.setAttribute("Co.","jb-aptech"

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

A.在aa.jsp中使用<formmethod=postaction="bb.jsp">把请求提交到bb.jsp

B.在aa.jsp中使用<jsp:forwardfile="bb.jsp"/>把页面重定向到bb.jsp

C.在aa.jsp中使用<%response.sendRedirect("bb.jsp");%>把页面重定向到bb.jsp

D.在aa.jsp中使用<%@includefile="bb.jsp"%>包含页面bb.jsp

E.在aa.jsp中使用<%config.getServletContext().getRequestDispatcher("/bb.jsp").forward(request,response);%>把页面重定向到bb.jsp


参考答案:D, E

第4题:

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

第5题:

在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

第6题:

Whichtwoarevalidandequivalent?()

A.<%!inti;%>

B.<%=inti;%>

C.<jsp:expr>inti;</jsp:expr>

D.<jsp:scriptlet>inti;</jsp:scriptlet>

E.<jsp:declaration>inti;</jsp:declaration>


参考答案:A, E

第7题:

WhichJSPstandardactioncanbeusedtoimportcontentfromaresourcecalledfoo.jsp?()

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

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

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

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


参考答案:C

第8题:

JSP EL表达式的语法为( )

A、!JSP expression

B、@{JSP expression}

C、${JSP expression}

D、#{JSP expression}


正确答案:C

第9题:

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

第10题:

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

更多相关问题