SCWCD(310-083)

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

第1题:

在一个Filter中,处理filter的业务的是()方法 

  • A、dealFilter(ServletRequest reg,ServletResponse res,FilterChain chain)
  • B、dealFilter(ServletRequest reg,ServletResponse res)
  • C、doFilter(ServletRequest reg,ServletResponse res,FilterChain chain)
  • D、doFilter(ServletRequest reg,ServletResponse res)

正确答案:C

第2题:

Given the definition of MyServlet: 11.public class MyServlet extends HttpServlet { 12.public void service(HttpServletRequest request, 13.HttpServletResponse response) 14.throws ServletException, IOException { 15.HttpSession session = request.getSession(); 16.session.setAttribute("myAttribute","myAttributeValue"); 17.session.invalidate(); 18.response.getWriter().println("value=" + 19.session.getAttribute("myAttribute")); 20.} 21.} What is the result when a request is sent to MyServlet?()

  • A、An IllegalStateException is thrown at runtime.
  • B、An InvalidSessionException is thrown at runtime.
  • C、The string "value=null" appears in the response stream.
  • D、The string "value=myAttributeValue" appears in the response stream.

正确答案:A

第3题:

You develop a Windows Communication Foundation (WCF) service to generate reports. Client applications call the service to initiate report generation but do not wait for the reports to be generated. The service does not provide any status to the client applications. The service class is defined as follows. (Line numbers are included for reference only.)01 [ServiceContract]02 public class ReportGeneratorService03 {04 ...05 private int GenerateReports(int clientID)06 {07 ...08 return 0;09 }10 }You need to ensure that client applications can initiate reports without waiting for status.Which two actions should you perform (Each correct answer presents part of the solution. Choose two.) ()。

A. Insert the following code at line 04. [OperationContract(IsOneWay=true)]

B. Insert the following code at line 04. [OperationContract(AsyncPattern=false)]

C. At line 05, change the GenerateReports method from private to public.

D. Remove line 08. At line 05, change the return type of GenerateReports method to void.


参考答案:A, D

第4题:

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

第5题:

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

第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题:

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

第8题:

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

第9题:

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

第10题:

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

更多相关问题