单选题Given a Filter class definition with this method: 21.public void doFilter(ServletRequest request, 22.ServletResponse response, 23.FilterChain chain) 24.throws ServletException, IOException { 25.// insert code here 26.} Which should you insert at line 2

题目
单选题
Given a Filter class definition with this method: 21.public void doFilter(ServletRequest request, 22.ServletResponse response, 23.FilterChain chain) 24.throws ServletException, IOException { 25.// insert code here 26.} Which should you insert at line 25 to properly invoke the next filter in the chain, or the target servlet if thereare no more filters?()
A

chain.forward(request, response);

B

chain.doFilter(request, response);

C

request.forward(request, response);

D

request.doFilter(request, response);

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

Given: 11.<% 12.request.setAttribute("vals", new String[]{"1","2","3","4"}); 13.request.setAttribute("index", "2"); 14.%> 15.<%-- insert code here --%> Which three EL expressions, inserted at line 15,are valid and evaluate to "3"?()

  • A、${vals.2}
  • B、${vals["2"]}
  • C、${vals.index}
  • D、${vals[index]}
  • E、${vals}[index]
  • F、${vals[vals[index-1]]}

正确答案:B,D,F

第2题:

1. public class a {  2. public void method1() {  3. try {  4. B b=new b();  5. b.method2();  6. // more code here  7. } catch (TestException te) {  8. throw new RuntimeException(te);  9. }  10. }  11. }  1. public class b {  2. public void method2() throws TestException {  3. // more code here  4. }  5. }  1. public class TestException extends Exception {  2. }  Given:  31. public void method() {  32. A a=new a();  33. a.method1();  34. }  Which is true if a TestException is thrown on line 3 of class b?()

  • A、 Line 33 must be called within a try block.
  • B、 The exception thrown by method1 in class a is not required to be caught.
  • C、 The method declared on line 31 must be declared to throw a RuntimeException.
  • D、 On line 5 of class a, the call to method2 of class b does not need to be placed in a try/catch block.

正确答案:B

第3题:

GivenaFilterclassdefinitionwiththismethod:21.publicvoiddoFilter(ServletRequestrequest,22.ServletResponseresponse,23.FilterChainchain)24.throwsServletException,IOException{25.//insertcodehere26.}Whichshouldyouinsertatline25toproperlyinvokethenextfilterinthechain,orthetargetservletiftherearenomorefilters?()

A.chain.forward(request,response);

B.chain.doFilter(request,response);

C.request.forward(request,response);

D.request.doFilter(request,response);


参考答案:B

第4题:

Given: 11.public class MyServlet extends HttpServlet { 12.public void service(HttpServletRequest request, 13.HttpServletResponse response) 14.throws ServletException, IOException { 15.// insert code here 16.} 17.} and this element in the web application’s deployment descriptor: 302 /html/error.html Which,inserted at line 15,causes the container to redirect control to the error.html resource?()

  • A、response.setError(302);
  • B、response.sendError(302);
  • C、response.setStatus(302);
  • D、response.sendRedirect(302);
  • E、response.sendErrorRedirect(302);

正确答案:B

第5题:

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

第6题:

Given an HttpServletRequest request and an HttpServletResponse response: 41.HttpSession session = null; 42.// insert code here 43.if(session == null) { 44.// do something if session does not exist 45.} else { 46.// do something if session exists47. } To implement the design intent,which statement must be inserted at line 42?()

  • A、session = response.getSession();
  • B、session = request.getSession();
  • C、session = request.getSession(true);
  • D、session = request.getSession(false);
  • E、session = request.getSession("jsessionid");

正确答案:D

第7题:

Which lines of code are valid declarations of a native method when occurring within the declaration of the following class?()    public class Qf575 {   // insert declaration of a native method here   }  

  • A、native public void setTemperature(int kelvin);
  • B、private native void setTemperature(int kelvin);
  • C、protected int native getTemperature();
  • D、public abstract native void setTemperature(int kelvin);
  • E、native int setTemperature(int kelvin) {}

正确答案:A,B

第8题:

Given: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

第9题:

1. public class A {  2. public void method1() {  3. B b=new B();  4. b.method2();  5. // more code here  6. }  7. }  1. public class B {  2. public void method2() {  3.C c=new C();  4. c.method3();  5. // more code here  6. }  7. }  1. public class C {  2. public void method3() {  3. // more code here  4. }  5. }  Given:  25. try {  26. A a=new A();  27. a.method1();  28. } catch (Exception e) {  29. System.out.print(”an error occurred”);  30. }  Which two are true if a NullPointerException is thrown on line 3 of class C?()

  • A、 The application will crash.
  • B、 The code on line 29 will be executed.
  • C、 The code on line 5 of class A will execute.
  • D、 The code on line 5 of class B will execute.
  • E、 The exception will be propagated back to line 27.

正确答案:B,E

第10题:

Given a Filter class definition with this method: 21.public void doFilter(ServletRequest request, 22.ServletResponse response, 23.FilterChain chain) 24.throws ServletException, IOException { 25.// insert code here26. } Which should you insert at line 25 to properly invoke the next filter in the chain,or the target servlet if thereare no more filters?()

  • A、chain.forward(request, response);
  • B、chain.doFilter(request, response);
  • C、request.forward(request, response);
  • D、request.doFilter(request, response);

正确答案:B

更多相关问题