第五章测试
1.在编写Servlet时需要( )。
A:实现HttpRequest B:继承HttpServlet C:继承Servlet D:实现HttpRequestServlet
答案:B
2.Servlet需要在( )文件中进行配置。
A:context.xml B:webapp.xml C:web.xml D:web.config 3.Servlet 可以在以下哪三个不同的作用域存储数据。( )
A:请求、会话和上下文 B:请求、响应和上下文 C:响应、会话和上下文 D:请求、响应和会话 4.给定一个Servlet的doGet方法中的代码片段,如下:
request.setAttribute(“name”,“zhang”);
response.sendRedirect(“http://localhost:8080/servlet/MyServlt”);
那么在 MyServlet中可以使用哪个方法把属性 name的值取出来。( )
A:无法取出来 B:String str = request.getAttribute(“name”); C:Object str = request.getAttribute(“name”); D:String str = (String)request.getAttribute(“name”); 5.包含Servlet发回到客户端信息的ServletResponse对象是由( )创建的。
A:Servlet对象 B:Web服务器的HTTP引擎 C:客户端的浏览器 D:Web服务器的Servlet容器 6.在J2EE中,对于HttpServlet类的描述,错误的是( )。
A:我们自己编写的servlet继承了Httpservlet类,一般只需要覆盖doPost方法,不必覆盖servive()方法,因为一个service()方法会调用doPost或者doGet方法 B:HttpServlet类扩展了GenericServlet类,实现了GenericServlet类的抽象方法 C:HttpServlet类中处理客户请求和响应时所使用的两个接口是:HttpServletRequest和HttpServletResponse D:我们自己编写的Servlet继承了HttpServlet类,一定需覆盖doPost或者doGet 7.

假设在helloapp应用中有一个HelloServlet类,它在web.xml文件中的配置如下:
<servlet>
<servlet-name> HelloServlet </servlet-name>
<servlet-class>org.javathinker.HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
那么在浏览器端访问HelloServlet的URL是什么? ( )


A:http://localhost:8080/HelloServlet B:http://localhost:8080/helloapp/HelloServlet C:http://localhost:8080/helloapp/org/javathinker/hello D:http://localhost:8080/helloapp/hello 8.使用Tomcat,通常会设置环境变量CATALINA_HOME指向安装目录; web应用程序的缺省部署目录在安装目录下的哪个子目录。( )
A:webapps B:Lib C:JAVA_HOME D:conf 9.不能在不同用户之间共享数据的方法是( )。
A:利用数据库 B:通过ServletContext对象 C:通过Cookie D:利用文件系统

温馨提示支付 ¥3.00 元后可查看付费内容,请先翻页预览!
点赞(73) dxwkbang
返回
顶部