java web复习题

上传人:hs****ma 文档编号:512581560 上传时间:2022-10-08 格式:DOC 页数:19 大小:170.50KB
返回 下载 相关 举报
java web复习题_第1页
第1页 / 共19页
java web复习题_第2页
第2页 / 共19页
java web复习题_第3页
第3页 / 共19页
java web复习题_第4页
第4页 / 共19页
java web复习题_第5页
第5页 / 共19页
点击查看更多>>
资源描述

《java web复习题》由会员分享,可在线阅读,更多相关《java web复习题(19页珍藏版)》请在金锄头文库上搜索。

1、1.假设在helloapp应用中有一个hello.jsp,它的文件路径如下: %CATALINA_HOME%/webapps/helloapp/hello/hello.jsp 那么在浏览器端访问hello.jsp的URL是什么? (单选)选项:(A) http:/localhost:8080/hello.jsp(B) http:/localhost:8080/helloapp/hello.jsp(C) http:/localhost:8080/helloapp/hello/hello.jsp2.假设在helloapp应用中有一个HelloServlet类,它位于org.javathinker包

2、下,那么这个类的class文件应该放在什么目录下? (单选)选项:(A) helloapp/HelloServlet.class(B) helloapp/WEB-INF/HelloServlet.class(C) helloapp/WEB-INF/classes/HelloServlet.class(D) helloapp/WEB-INF/classes/org/javathinker/HelloServlet.class3.假设在helloapp应用中有一个HelloServlet类,它在web.xml文件中的配置如下: HelloServlet org.javathinker.HelloS

3、ervlet HelloServlet /hello那么在浏览器端访问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/hello4.客户请求访问HTML页面与访问Servlet有什么异同?(多选)选项:(A)相同:都使用HTTP协议(B)区别:前

4、者Web服务器直接返回HTML页面,后者Web服务器调用Servlet的方法,由Servlet动态生成HTML页面(C)相同:前者Web服务器直接返回HTML页面,后者Web服务器直接返回Servlet的源代码。(D)区别:后者需要在web.xml中配置URL路径。(E)区别:前者使用HTTP协议,后者使用RMI协议。5.HttpServletRequest对象是由谁创建的?(单选)选项:(A)由Servlet容器负责创建,对于每个HTTP请求, Servlet容器都会创建一个HttpServletRequest对象(B)由JavaWeb应用的Servlet或JSP组件负责创建,当Servle

5、t或JSP组件响应HTTP请求时,先创建HttpServletRequest对象6.从HTTP请求中,获得请求参数,应该调用哪个方法? (单选)选项:(A)调用HttpServletRequest对象的getAttribute()方法(B)调用ServletContext对象的getAttribute()方法(C)调用HttpServletRequest对象的getParameter()方法7.ServletContext对象是由谁创建的?(单选)选项:(A)由Servlet容器负责创建,对于每个HTTP请求, Servlet容器都会创建一个ServletContext对象(B)由JavaWe

6、b应用本身负责为自己创建一个ServletContext对象(C)由Servlet容器负责创建,对于每个JavaWeb应用,在启动时,Servlet容器都会创建一个ServletContext对象8.jspForward1.jsp要把请求转发给jspForward2.jsp,应该在jspForward1.jsp中如何实现? (单选)选项:(A) jspForward2.jsp (B) 9.当浏览器第二次访问以下JSP网页时的输出结果是什么?(单选)a: b:选项:(A) a=0 b=0(B) a=1 b=1(C) a=2 b=110.下面哪个说法是正确的? (单选)选项:(A) 对于每个要求访

7、问maillogin.jsp的HTTP请求,Servlet容器都会创建一个HttpSession对象(B)每个HttpSession对象都有惟一的ID。(C)JavaWeb应用程序必须负责为HttpSession分配惟一的ID11.如果不希望JSP网页支持Session,应该如何办? (单选)选项:(A) 调用HttpSession的invalidate()方法 (B) 12.以下代码能否编译通过,假如能编译通过,运行时得到什么打印结果?(单选)request.setAttribute(count,new Integer(0);Integer count = request.getAttrib

8、ute(count);选项:(A)不能编译通过(B)能编译通过,并正常运行 (C) 编译通过,但运行时抛出ClassCastException13.J2EE 中, 类的 方法用于创建对话。(选择一项)a) HttpServletRequest、getSessionb) HttpServletResponse、newSessionc) HtttpSession、newInstanced) HttpSession、getSession14.给定一个 Servlet 的doGet方法中的代码片段,如下: request.setAttribute(name,zhang); response.sendR

9、edirect(http:/localhost:8080/servlet/MyServlt); 那么在 MyServlet 中可以使用 方法把属性 name的值取出来。(单选)a) String str=request.getAttribute(name);b) String str=(String)request.getAttribute(name);c) Object str=request.getAttribute(name);d) 无法取出来15.以下 可用于检索session属性userid的值。(单选)A.session. getAttribute (userid);B.sessi

10、on. setAttribute (userid);C.request. getParameter (userid);D.request. getAttribute (userid);16.在J2EE中,以下对RequestDispatcher描述正确的是 。(单选)A.Jsp中有个隐含的对象diapatcher,它的类型是RequestDispatcherB.ServletConfig有一个方法:getRequestDispatcher可以返回RequestDipatcher对象C.RequestDipatcher 有一个方法:forward可以把请求继续传递给别的Servlet或者JSP界

11、面D.JSP中有个隐含的默认对象request,它的类型是RequestDipatcher17.在WEB应用程序的目录结构中,在WEB-INF文件夹外的文件为()。(单选)A.jsp文件B.class文件C.jar文件D.web.xml文件18.给定一个Servlet程序的代码片段,如下:Public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException request.getSession().getAttribute(A); /第二行假

12、定第二行返回的对象引用不是null,那么这个对象存储在 范围中。(单选)A.pageB.sessionC.requestD.application19.在J2EE中在servletl中的doGet和doPost方法中只有如下代码: Request.setAttribute(jb,aPtech); response.sendRedirect(http:localhost:8080servletServlet2); 那么在Servlet2 中使用 可以把属性jb的值取出来。(单选)A.String str = request.getAttribute(jb);B.String sir =(Stri

13、ng)request.getAttribute(jb);C.Object str = request.getAttribute(jb);D.取不出来20.给定一个Servlet的代码片段如下:public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException_ _out.println(“hi kitty!”);out.close();运行次Servlet时输出如下:hi kitty!则应在此Servlet下划线处填充如下代码。(单选)A.P

14、rintWriter out = response.getWriter();B.PrintWriter out = request.getWriter();C.OutputStream out = response.getOutputStream();D.OutputStream out = request.getWriter();21.在Servlet中,下列语句可以正确获取PrintWriter对象的是()。(只选一项)A.PrintWriter out= request.getWriter();B.PrintWriter out = request.getPrintWriter();C.PrintWrit

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 建筑/环境 > 施工组织

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号