Given the HttpServlet code:   getServletContext().setAttribute(“foo”, “value”); What is the result?()A、 The attribute foo is placed in the applicationB、 A ServletContextListener registered for that servlet is notifiedC、 A ServletAttributeListener registe

题目

Given the HttpServlet code:   getServletContext().setAttribute(“foo”, “value”); What is the result?()

  • A、 The attribute foo is placed in the application
  • B、 A ServletContextListener registered for that servlet is notified
  • C、 A ServletAttributeListener registered for that servlet is notified
  • D、 An HttpSessionAttributeListener registered for that servlet is notified

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

    Given: String value = getServletContext().getInitParameter("foo"); in an HttpServlet and a web applicationdeployment descriptor that contains: foo frodo Which two are true?()

    • A、The foo initialization parameter CANNOT be set programmatically.
    • B、Compilation fails because getInitParameter returns type Object.
    • C、The foo initialization parameter is NOT a servlet initialization parameter.
    • D、Compilation fails because ServletContext does NOT have a getInitParameter method.
    • E、The foo parameter must be defined within the  element of the deployment descriptor.

    正确答案:A,C

  • 第2题:

    自定义的servlet应重载Httpservlet类的()方法以响应客户发出的post 请求方法。

    • A、Post
    • B、Onpost
    • C、doPost
    • D、Responspost

    正确答案:C

  • 第3题:

    HttpServlet类中定义了Servlet对象必须实现的init(),Service(),destroy()等方法。()


    正确答案:错误

  • 第4题:

    HttpServlet是定义在()套件之中。

    • A、javax.servlet
    • B、javax.servlet.http
    • C、java.http
    • D、javax.http

    正确答案:C

  • 第5题:

    下列对HttpServlet类描述错误的是()

    • A、HttpServlet类是针对使用Http协议的Web服务器的Servlet类
    • B、HttpServlet类通过执行Servlet借口,能够提供Http协议的功能
    • C、HttpServlet的子类实现了doGet()方法去响应HTTP的Get请求
    • D、HttpServlet的子类实现了doPost()方法去响应HTTP的Post请求
    • E、HttpServlet类通过init()方法和destory()方法管理Servlet自身的资源

    正确答案:E

  • 第6题:

    下列哪项不是HttpServlet的方法()

    • A、init()
    • B、destroy()
    • C、doPost()
    • D、execute()

    正确答案:D

  • 第7题:

    多选题
    在J2EE中,对于HttpServlet类的描述,正确的是()。
    A

    我们自己编写的Servlet继承了HttpServlet类,一般只需覆盖doPost或者doGet方法,不必覆盖service()方法。因为一个service()方法是空的

    B

    HttpServlet类扩展了GenericServlet类,实现了GenericServlet类的抽象方法service()

    C

    HttpServlet类有两个service()方法

    D

    我们自己编写的Servlet继承了HttpServlet类,一般只需覆盖doPost或者doGet方法,不必覆盖service()方法。因为一个service()方法会调用doPost或者doGet方法


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

  • 第8题:

    单选题
    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);


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

  • 第9题:

    单选题
    J2EE中,当把来自客户机的HTTP请求委托给servlet时,会调用HttpServlet的()方法。
    A

    service

    B

    doget

    C

    dopost

    D

    init


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

  • 第10题:

    单选题
    HttpServlet中,用来处理POST请求的方法是()
    A

    doHead

    B

    doGet

    C

    doPost

    D

    doPut


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

  • 第11题:

    多选题
    Given: String value = getServletContext().getInitParameter("foo"); in an HttpServlet and a web applicationdeployment descriptor that contains: foo frodo Which two are true?()
    A

    The foo initialization parameter CANNOT be set programmatically.

    B

    Compilation fails because getInitParameter returns type Object.

    C

    The foo initialization parameter is NOT a servlet initialization parameter.

    D

    Compilation fails because ServletContext does NOT have a getInitParameter method.

    E

    The foo parameter must be defined within the  element of the deployment descriptor.


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

  • 第12题:

    单选题
    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.


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

  • 第13题:

    Why does IS-IS use the SPF algorithm?()

    • A、to determine the pseudonode ID
    • B、to determine the next hop to a given destination
    • C、to determine the complete path to a given destination
    • D、to determine the number of routers present in a given area

    正确答案:B

  • 第14题:

    HttpServlet类中定义了Servlet对象必须实现()。

    • A、Stop()
    • B、Init()
    • C、Service()
    • D、Destroy()

    正确答案:B,C,D

  • 第15题:

    J2EE中以下关于HttpServlet的说法错误的是()

    • A、 HttpServlet是一个抽象类
    • B、 HttpServlet类扩展了GenericServlet类
    • C、 HttpServlet类的子类必须至少重写service方法
    • D、 HttpServlet位于javax.servlet.http包中

    正确答案:C

  • 第16题:

    在J2EE中,对于HttpServlet类的描述,错误的是()。

    • A、我们自己编写的Servlet继承了HttpServlet类,一定需覆盖doPost或者doGet
    • B、Httpservlet类扩展了GenericServlet类,实现了GenericServlet类的抽象方法
    • C、Httpservlet类中处理客户请求和响应时所使用的两个接口是:HttpServletRequest和HttpServletResponse
    • D、我们自己编写的servlet继承了Httpservlet类,一般只需要覆盖doPost或doGet方法,不必覆盖servive()方法,因为一个service()方法会调用doPost或者doGet方法

    正确答案:A

  • 第17题:

    JAVA EE中,当把来自客户机的HTTP请求委托给servlet时,会调用HttpServlet的()方法。

    • A、service
    • B、doGet
    • C、doPost
    • D、init

    正确答案:A

  • 第18题:

    编写Servlet的doPost方法时,需要抛出的异常是() 

    • A、ServletException,IOException
    • B、ServletException,RemoteException
    • C、HttpServlet Exception,IOException
    • D、HttpServletException,RemoteException

    正确答案:A

  • 第19题:

    单选题
    Given an HttpServlet Request request and Http Servlet Response response, which sets a cookie “username” with the value “joe” in a servlet.?()
    A

     request.add Cookie (“username”. “joe”)

    B

     request.set Cookie (“username, “joe”)

    C

     response.add Cookie (username”, “joe”))

    D

     request.add Header (new Cookie (“username”, “joe”))

    E

     request.add Cookie (new Cookie (“username”, “joe”))

    F

     response.add Cookie (new Cookie (“username”, “joe”))

    G

     response.add Header (new Cookie (“username”, “joe”))


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

  • 第20题:

    单选题
    在J2EE中,对于HttpServlet类的描述,错误的是()。
    A

    我们自己编写的Servlet继承了HttpServlet类,一定需覆盖doPost或者doGet

    B

    Httpservlet类扩展了GenericServlet类,实现了GenericServlet类的抽象方法

    C

    Httpservlet类中处理客户请求和响应时所使用的两个接口是:HttpServletRequest和HttpServletResponse

    D

    我们自己编写的servlet继承了Httpservlet类,一般只需要覆盖doPost或doGet方法,不必覆盖servive()方法,因为一个service()方法会调用doPost或者doGet方法


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

  • 第21题:

    判断题
    HttpServlet类中定义了Servlet对象必须实现的init(),Service(),destroy()等方法。()
    A

    B


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

  • 第22题:

    单选题
    J2EE中以下关于HttpServlet的说法错误的是()
    A

     HttpServlet是一个抽象类

    B

     HttpServlet类扩展了GenericServlet类

    C

     HttpServlet类的子类必须至少重写service方法

    D

     HttpServlet位于javax.servlet.http包中


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

  • 第23题:

    单选题
    Given the HttpServlet code:   getServletContext().setAttribute(“foo”, “value”); What is the result?()
    A

     The attribute foo is placed in the application

    B

     A ServletContextListener registered for that servlet is notified

    C

     A ServletAttributeListener registered for that servlet is notified

    D

     An HttpSessionAttributeListener registered for that servlet is notified


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