【单选题】阅读下面代码片段:[br][/br]Servlet1:[br][/br] response.getWriter().write(“hello,servlet1”);[br][/br] request.getRequestDispatcher().include(“Servlet2”);[br][/br]Servlet2: [br][/br] response.setHeader(“Refresh”,”1”);[br][/br] response.getWriter().write(“,servlet2”);[br][/br]下面选项中,关于运行结果说法正确的是( )
A: 正常显示:hello,servlet1,servlet2
B: 正常显示:hello,servlet1,servlet2,并且页面会不断刷新
C: 正常显示:,servlet2
D: 正常显示:hello,servlet1
A: 正常显示:hello,servlet1,servlet2
B: 正常显示:hello,servlet1,servlet2,并且页面会不断刷新
C: 正常显示:,servlet2
D: 正常显示:hello,servlet1
举一反三
- 阅读下面代码片段:Servlet1:response.getWriter().write(“hello,servlet1”);request.getRequestDispatcher().include(“Servlet2”);Servlet2:response.setHeader(“Refresh”,”1”);response.getWriter().write(“,servlet2”); A: 正常显示:hello,servlet1,servlet2 B: 正常显示:hello,servlet1,servlet2,并且页面会不断刷新 C: 正常显示:,servlet2 D: 正常显示:hello,servlet1
- 阅读下面代码片段: Servlet1: response.getWriter().write(“hello,servlet1”); request.getRequestDispatcher().include(“Servlet2”); Servlet2: response.setHeader(“Refresh”,”1”); response.getWriter().write(“,servlet2”);
- 阅读下面代码片段: Servlet1: response.setContentType("text/html;charset=gbk"); response.getWriter().write("传播智慧"); request.getRequestDispatcher("/servlet/Servlet2") .forward(request,response); response.sendRedirect("/app/servlet/Servlet3"); Servlet2: response.getWriter().write("收获成长"); 请问当浏览器访问Servlet1时会有什么样的输出
- 在Java Web应用程序中,包含两个名为Servlet1和Servlet2的HttpServlet,在web.xml中指定Servlet2的访问路径为“/Servlet2”,Servlet1的doGet方法中的代码为:[br][/br]PrintWriter out = response.getWriter();[br][/br]out.print (“Servlet”); ______________ context = getServletContext(); RequestDispatcher dispatcher = context.____________(“/servlet2”); [br][/br]dispatcher.___________(____________,response);[br][/br]out.close();[br][/br]Servlet2的doGet方法中的代码为:[br][/br]PrintWriter out = response.getWriter();[br][/br]out.print(“Servlet2”);[br][/br]out.close();[br][/br]如果用户在浏览器中访问Servlet1,则浏览器显示内容为:__________________________
- 阅读下面代码片段[img=525x134]17e0acea8796010.png[/img]下面选项中,关于运行结果说法正确的是() A: 正常显示:hello,servlet1,servlet2 B: 正常显示:hello,servlet1,servlet2,并且页面会不断刷新 C: 正常显示:,servlet2 D: 正常显示:hello,servlet1