java工程师信产部认证考试

编写Servlet的doPost方法时,需要抛出的异常是() A、ServletException,IOExceptionB、ServletException,RemoteExceptionC、HttpServlet Exception,IOExceptionD、HttpServletException,RemoteException

题目

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

  • A、ServletException,IOException
  • B、ServletException,RemoteException
  • C、HttpServlet Exception,IOException
  • D、HttpServletException,RemoteException
如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

在J2EE中,给定某Servlet的代码如下,编译运行该文件,以下陈述正确的是( )

public class Servletl extends HttpServlet{

public void init() throws ServletException{

}

public void service(HttpServletRequest

request,HttpServletResponse response)throws

ServletException,IOException{

PrintWriter ut=response.getWriter();

out.println(“hello!”);

}

}

A、编译该文件时会提示缺少doGet()或者doPost()方法,编译不能够成功通过

B、编译后,把Servletl.class放在正确位置,运行该Servlet,在浏览器中会看到输出文字:hello!

C、编译后,把Servletl.class放在正确位置,运行该Servlet,在浏览器中会看不到任何输出的文字

D、编译后, 把Servletl.class放在正确位置,运行该Servlet,在浏览器中会看到运行期错误信息


正确答案:B

第2题:

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)

第3题:

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

A.ServletException,IOException

B.ServletException,RemoteException

C.HttpServletException,IOException

D.HttpServletException,RemoteException


参考答案:A

第4题:

在J2EE中,有如下代码在Servlet1.java中。  import javax.servlet.*;  import javax.servlet.http.*;  import java.io.IOException;  import java.io.PrintWriter;  public class Servlet1 extends HttpServlet {    public void init()  throws ServletException {   }  public void service(HttpServletRequest request, HttpServletResponse response)  throws ServletException, IOException {      PrintWriter out = response.getWriter();      out.println("hello!");   } }   假如编译Servlet要具备的环境都已经建立好。现在用完全正确的命令编译该文件,对于以下陈述正确的是()。 

  • A、编译该文件时会提示缺少doGet()或者doPost()方法,编译不能够成功通过
  • B、编译后,把Servlet1.class放在正确位置,在浏览器中查看该Servlet1,会看到输出文字:“hello!”
  • C、编译后,把Servlet1.class放在正确位置,在浏览器中查看该Servlet1,却看不到任何输出的文字
  • D、编译后,把Servlet1.class放在正确位置,在浏览器中查看该Servlet1,却看到产生运行时错误的出错信息

正确答案:B

第5题:

下面哪个方法不是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

第6题:

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

A、GenericServlet

B、ServletResponse

C、ServletRequest

D、HttpServlet


正确答案:AD

第7题:

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

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

正确答案:A

第8题:

在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方法


参考答案:B, C, D

第9题:

在J2EE中,有如下代码在Servlet1.Java中    Import javax.servlet.*;    Import javax.servlet.http.*    Import java.io.IOException;     Import java.io.PrintWriter;    Public class Servlet1 extends HttpServlet{  Public void init () throw ServletException {}   Public void service(HttpServletRequest request,  HttpServletResponce response) throws ServletException,IOException{  PrintWriter out=response.getWriter();   Out.println(“hello!”); } }  假如编译Servlet要具备的环境都已经建立好。现在用完全正确的命令编译该文件,对于以下成熟正确的是()  

  • A、编译该晚间时会提示缺少doGe()t或者doPost(),编译不能够成功通过
  • B、编译后,把Serlvet.cass放在正确的位置,在浏览器中查看该Servlet1,会看到输出文在:“hello!”
  • C、编译后,把Servlet.class放在正确的位置,在浏览器中查看该Servlet1,却看不到任何输出的文字
  • D、编译后,把Servlet.class放在正确的位置,在浏览器中查看该Servlet1,却看到产生运行时错误的出错信息

正确答案:B

第10题:

在J2EE中,Servlet1的代码如下:  import javax.servlet.*;  import javax.servlet.http.*; import java.io.*;  public class Servlet1 extends HttpServlet {  public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {      response.setContentType("text/html");      PrintWriter out = response.getWriter();      String aa=request.getQueryString();      String bb=request.getMethod();      out.println(aa);  out.println(bb);   } }  把Servlet1.class文件放在Web服务器适合的目录下,在浏览B器地址栏内输入:http://localhost:8080/servlet/Servlet1?name=jb-aptech&phone=12345678,看到的结果是()。 

  • A、name=jb-aptech&phone=12345678 GET
  • B、name=jb-aptech,phone=12345678 GET
  • C、jb-aptech,12345678 POST
  • D、name,phone GET
  • E、2,POST

正确答案:A

更多相关问题