参考答案和解析
正确答案:

 

doGet() 和 doPost() 接收两个参数:HttpServletRequest 请求和HttpServletResponse响应。

HTTP 协议要么通过在 URL 中放置参数来向 Web 服务器传递信息,要么独立于 URL 传递信息。第一种称

作 GET 命令,而第二种称作 POST 命令。GET 命令的优点是,URL 包含了检索请求信息所需的所有信息

。因此,可将其加入书签以便将来重新调用。而 POST 命令独立于 URL 发送附加信息,提供了更好的安

全性。当需要发送比较大量的信息时,该方法也更为合适。其缺点就是不能被加入书签。

更多“3 doGet() 和 doPost() 的区别?”相关问题
  • 第1题:

    什么情况下调用doGet()和doPost()?


    正确答案:

     

    Jsp 页面中的FORM. 标签里的method 属性为get 时调用doGet(),为post 时调用

    doPost()。

  • 第2题:

    下面关于Servlet生命周期,说法不正确的是()。 

    • A、 在创建自己的Servlet时候,应该在初始化方法init()方法中创建Servlet实例
    • B、 在Servlet生命周期的服务阶段,执行service()方法,根据用户请求的方法,执行相应的doGet()或是doPost()方法
    • C、 在销毁阶段,执行destroy()方法后系统立刻进行垃圾回收
    • D、 destroy()方法仅执行一次

    正确答案:A,C

  • 第3题:

    下列论述HTTP协议中doGet和doPost方法的命题中,哪些是正确的()

    • A、doGet适用大量数据传输
    • B、doPost适用大量数据传输
    • C、默认情况下doPost将Form中参数和值显示在URL中
    • D、默认情况下doGet将Form中参数和值显示在URL中

    正确答案:B,D

  • 第4题:

    在编写Servlet时,需要继承()类,在Servlet中声明doGet( )和doPost( )需要()和()类型的两个参数。


    正确答案:HttpServlet;HttpRequest;HttpResponse

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

    servlet的生命周期由它的3个方法来控制,它们是()。

    • A、init()
    • B、service()
    • C、destroy()
    • D、doGet()
    • E、doPost()

    正确答案:A,B,C

  • 第8题:

    Servlet的初始化参数只能在Servlet的()方法中获取。

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

    正确答案:A

  • 第9题:

    下列有关Servlet的生命周期,哪一种是错误的解释?()

    • A、在创建自己的Servlet时候,应该在初始化方法init()方法中创建Servlet实例
    • B、在Servlet生命周期的服务阶段,执行service()方法,根据用户请求的方法,执行相应的doGet()或是doPost()方法
    • C、在销毁阶段,执行destroy()方法后系统立刻进行垃圾回收
    • D、destroy()方法仅执行一次,即在服务器停止且卸载Servlet时执行该方法

    正确答案:A

  • 第10题:

    填空题
    在编写Servlet时,需要继承()类,在Servlet中声明doGet( )和doPost( )需要()和()类型的两个参数。

    正确答案: HttpServlet,HttpRequest,HttpResponse
    解析: 暂无解析

  • 第11题:

    多选题
    下面关于Servlet生命周期,说法不正确的是()。
    A

    在创建自己的Servlet时候,应该在初始化方法init()方法中创建Servlet实例

    B

    在Servlet生命周期的服务阶段,执行service()方法,根据用户请求的方法,执行相应的doGet()或是doPost()方法

    C

    在销毁阶段,执行destroy()方法后系统立刻进行垃圾回收

    D

    destroy()方法仅执行一次


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

  • 第12题:

    ( 难度:中等)编写一个Servlet的步骤包含以下哪几个()
    A.创建一个类继承HttpServlet
    B.重写doPost与doGet方法
    C.重写init(ServletConfig confg)方法
    D.在wexml对Servlet进行配置
    E.重写close()方法

    答案:ABD

  • 第13题:

    Servlet的基本架构

    public class ServletName extends HttpServlet {

    public void doPost(HttpServletRequest request, HttpServletResponse response) throws

    ServletException, IOException {

    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws

    ServletException, IOException {

    }

    }

    1、用String的方法将数据类型转换为String。


    正确答案:

     

    1、String.valueOf(1.23)

  • 第14题:

    下面哪个方法不是HttpServlet类:()

    • A、protected void doGet(HttpServletRequest reg,HttpServletResponse res) throws Servlet Exception ,java.io.IOException
    • B、protected void doPost(HttpServletRequest reg,HttpServletResponse res) throws Servlet Exception,java.io.IOException
    • C、protected void doHead(HttpServletRequest reg,HttpServletResponse res) throws Servlet Exception,java.io.IOException
    • D、protected void doReceive(HttpServletRequest reg,HttpServletResponse res) throws ServletException,java.io.IOException

    正确答案:D

  • 第15题:

    在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

  • 第16题:

    开发JavaWeb应用程序时,创建了一个Servlet,该Servlet重写了其父类的doGet和doPost方法,那么其父类可能是()

    • A、RequestDispatcher
    • B、HttpServletResponse
    • C、HttpServletRequest
    • D、HttpServlet

    正确答案:D

  • 第17题:

    哪个不是Servlet接口的方法?()

    • A、doGet方法
    • B、doPost方法
    • C、init方法
    • D、forward方法

    正确答案:D

  • 第18题:

    Servlet程序的入口点是()。

    • A、init()
    • B、main()
    • C、service()
    • D、doGet()

    正确答案:A

  • 第19题:

    下列哪一项不是Servlet中使用的方法?()

    • A、doGet()
    • B、doPost()
    • C、service()
    • D、close()

    正确答案:D

  • 第20题:

    一旦初始化了Servlet,Servlet就能随时等候处理请求。对于每一个请求,通常调用service方法。service方法会根据所接收到的HTTP请求的类型调用以下哪些方法?()

    • A、doGet()
    • B、doPost()
    • C、doPut()
    • D、doCreate()

    正确答案:A,B,C

  • 第21题:

    Which two statements are true about using the isUserInRole method to implement security in a Java EEapplication?()

    • A、It can be invoked only from the doGet or doPost methods.
    • B、It can be used independently of the getRemoteUser method.
    • C、Can return "true" even when its argument is NOT defined as a valid role name in the deployment descriptor.
    • D、Using the isUserInRole method overrides any declarative authentication related to the method in which it is invoked.

    正确答案:B,C

  • 第22题:

    多选题
    下列论述HTTP协议中doGet和doPost方法的命题中,哪些是正确的()
    A

    doGet适用大量数据传输

    B

    doPost适用大量数据传输

    C

    默认情况下doPost将Form中参数和值显示在URL中

    D

    默认情况下doGet将Form中参数和值显示在URL中


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

  • 第23题:

    多选题
    Which two statements are true about using the isUserInRole method to implement security in a Java EEapplication?()
    A

    It can be invoked only from the doGet or doPost methods.

    B

    It can be used independently of the getRemoteUser method.

    C

    Can return true even when its argument is NOT defined as a valid role name in the deployment descriptor.

    D

    Using the isUserInRole method overrides any declarative authentication related to the method in which it is invoked.


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