A.在这两行代码前加上代码:response.setContentType(“text/html,charset=GBK”);
B.已经可以显示汉字,不用添加任何代码
C.在这两行代码前加上代码:response.setContentType(“text/html”);
D.在这两行代码前加上代码:response.setContentType(“text/html,charset=gb2312”);
第1题:
在J2EE中,有如下代码在Servlet1.Java中Importjavax.servlet.*;Importjavax.servlet.http.*Importjava.io.IOException;Importjava.io.PrintWriter;PublicclassServlet1extendsHttpServlet{Publicvoidinit()throwServletException{}Publicvoidservice(HttpServletRequestrequest,HttpServletResponceresponse)throwsServletException,IOException{PrintWriterout=response.getWriter();Out.println(hello!”);}}假如编译Servlet要具备的环境都已经建立好。现在用完全正确的命令编译该文件,对于以下成熟正确的是()
A.编译该晚间时会提示缺少doGe()t或者doPost(),编译不能够成功通过
B.编译后,把Serlvet.cass放在正确的位置,在浏览器中查看该Servlet1,会看到输出文在:“hello!”
C.编译后,把Servlet.class放在正确的位置,在浏览器中查看该Servlet1,却看不到任何输出的文字
D.编译后,把Servlet.class放在正确的位置,在浏览器中查看该Servlet1,却看到产生运行时错误的出错信息
第2题:
定一个Servlet的代码片段如下: Publicvoid doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{ ______ out.println(“hi kitty!”); out.close(); } 运行次Servlet时输出如下: hikitty! 则应在此Servlet下划线处填充如下代码()
A.PrintWriter out =response.getWriter();
B.PrintWriter out =request.getWriter();
C.OutputStream out =response.getOutputStream();
D.OutputStream out =request.getWriter();
第3题:
8、给定一个Servlet的代码片段如下: () public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{ ______ out.println(“hi kitty!”); out.close(); } 运行此Servlet时输出如下: hi kitty! 则应在此Servlet下划线处填充如下代码。
A.PrintWriter out = response.getWriter();
B.PrintWriter out = request.getWriter();
C.OutputStream out = response.getOutputStream();
D.OutputStream out = request.getWriter();
第4题:
A.在这两行代码前加上代码:response.setContentType("text/html,charset=GBK");
B.已经可以显示汉字,不用添加任何代码
C.在这两行代码前加上代码:response.setContentType("text/html");
D.在这两行代码前加上代码:response.setContentType("text/html,charset=gb2312");
第5题:
3、给定一个Servlet的代码片段如下: public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException{ __________ out.println(“hi kitty!”); out.close(); } 运行此Servlet时输出如下: hi kitty! 则应在此Servlet下划线处填充代码()。
A.PrintWriter out = request.getWriter()
B.OutputStream out = response.getOutputStream()
C.OutputStream out = request.getWriter()
D.PrintWriter out = response.getWriter()