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()
第1题:
在j2ee中,有如下代码在servlet1.java中Importantjavax.servelt.*;Importantjavax.servlet.http.*Importjava.io.ioexceptionImportjava.io.printwriterPublicclassservlet1extendshttpservlet{Publicvoidinit()throwsserveltexception{}Publicvoidservice(httpserveltrequestrequest,httpserbletresponseresponse)throwsservletexception,ioexception{Printwriterout=response.getwriter();Out.println(hello”);}}假如编译serblet要具备的环境都已经建立好,现在用完全正确的命令编译该文件,对于以下陈述正确的是()
A.编译该文件时会提示缺少doget()或者dopost()方法,编译不能够成功通过
B.编译后,把servlet1.class放在正确位置,在浏览器中查看该servlet1,会看到输出文字:“hello”
C.编译后,把servlet1.class放在正确位置,在浏览器中查看该servlet1,却看不到任何输出的文字
D.编译后,把servlet1.class放在正确位置,在浏览器中查看该servlet1,却看到产生运行时错误的出差信息
第2题:
A.Stringstr=request.getAttribute("jb");
B.Stringstr=(String)request.getAttribute("jb");
C.Objectstr=request.getAttribute("jb");
D.取不出来
第3题:
给定某servlet 程序的片段,如下:
Public void doGet(HttpServletRequest
request,Httpservletresponse response)
{
_________
}
要把session的失效时间设为30分钟,应该在下划线处插入( )
A、request.getSession().setTimeout(1800);
B、request.getSession().setTimeout(30)
C、request.getSession().setMaxInactiveInterval(1800);
D、request.getSession().setMaxInactiveInterval(30);
第4题:
请在下划线处填入代码,使程序能够正确运行。
import java .awt.*;
import java .applet.*;
public class SayHi extends Applet{
public void【 】(Graphics g){
g .drawString(“Hi!”20,20);
}
}
第5题:
下面哪个方法不是HttpServlet类:()
第6题:
Which two prevent a servlet from handling requests.?()
第7题:
Given: 11.public class MyServlet extends HttpServlet { 12.public void service(HttpServletRequest request, 13.HttpServletResponse response) 14.throws ServletException, IOException { 15.// insert code here 16.} 17.} and this element in the web application’s deployment descriptor:
第8题:
response.setError(302);
response.sendError(302);
response.setStatus(302);
response.sendRedirect(302);
response.sendErrorRedirect(302);
第9题:
编译该文件时会提示缺少doget()或者dopost()方法,编译不能够成功通过
编译后,把servlet1.class放在正确位置,在浏览器中查看该servlet1,会看到输出文字:“hello”
编译后,把servlet1.class放在正确位置,在浏览器中查看该servlet1,却看不到任何输出的文字
编译后,把servlet1.class放在正确位置,在浏览器中查看该servlet1,却看到产生运行时错误的出差信息
第10题:
编译文件时会提醒缺少doGet和doPost方法,编译不能成功通过
编译后,把Servlet.Class放在正确的位置,在浏览器查看该Servlet会看到输出文字:“hello”
编译后,把Servlet.Class放在正确的位置,在浏览器查看该Servlet却看不到任何文字
编译后,把Servlet.Class放在正确的位置,在浏览器查看该Servlet会却看到运行时的错误信息
第11题:
Dispatcher view=context.getDispatcher(viewURL);view.forward Request(request, response);
Dispatcher view=request.getDispatcher(viewURL);view.forward Request(request, response);
RequestDispatcher view. =context.getRequestDispatcher(viewURL);view.forward(request,response);
RequestDispatcher view=request.getRequestDispatcher(viewURL);view.forward(request, response);
第12题:
The servlet’s init method returns a non-zero status.
The servlet’s init method throws a Servlet Exception
The servlet’s init method sets the Servlet Response’s context length to 0
The servlet’s init method sets the Servlet Response’s content type to null.
The servlet’s init method does NOT return within a time period defined by the servlet container.
第13题:
在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,却看到产生运行时错误的出错信息
第14题:
在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,在浏览器中会看到运行期错误信息
第15题:
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)
第16题:
Given a Filter class definition with this method: 21.public void doFilter(ServletRequest request, 22.ServletResponse response, 23.FilterChain chain) 24.throws ServletException, IOException { 25.// insert code here 26.} Which should you insert at line 25 to properly invoke the next filter in the chain, or the target servlet if thereare no more filters?()
第17题:
在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要具备的环境都已经建立好。现在用完全正确的命令编译该文件,对于以下陈述正确的是()。
第18题:
在J2EE中,有如下代码在Servlet1.java中。 importjavax.servlet.*; importjavax.servlet.http.*; importjava.io.IOException; importjava.io.PrintWriter; publicclassServlet1extendsHttpServlet{publicvoidinit()throwsServletException{} publicvoidservice(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{ PrintWriterout=response.getWriter(); out.println("hello!");}} 假如编译Servlet要具备的环境都已经建立好。现在用完全正确的命令编译该文件,对于以下陈述正确的是()。
第19题:
Given an HttpServletRequest request and HttpServletResponse response,which sets a cookie "username"with the value "joe" in a servlet?()
第20题:
编译该晚间时会提示缺少doGe()t或者doPost(),编译不能够成功通过
编译后,把Serlvet.cass放在正确的位置,在浏览器中查看该Servlet1,会看到输出文在:“hello!”
编译后,把Servlet.class放在正确的位置,在浏览器中查看该Servlet1,却看不到任何输出的文字
编译后,把Servlet.class放在正确的位置,在浏览器中查看该Servlet1,却看到产生运行时错误的出错信息
第21题:
编译该文件时会提示缺少doGet()或者doPost()方法,编译不能够成功通过
编译后,把Servlet1.class放在正确位置,在浏览器中查看该Servlet1,会看到输出文字:“hello!”
编译后,把Servlet1.class放在正确位置,在浏览器中查看该Servlet1,却看不到任何输出的文字
编译后,把Servlet1.class放在正确位置,在浏览器中查看该Servlet1,却看到产生运行时错误的出错信息
第22题:
chain.forward(request, response);
chain.doFilter(request, response);
request.forward(request, response);
request.doFilter(request, response);
第23题:
name=jb-aptech&phone=12345678 GET
name=jb-aptech,phone=12345678 GET
jb-aptech,12345678 POST
name,phone GET
2,POST
第24题:
An IllegalStateException is thrown at runtime.
An InvalidSessionException is thrown at runtime.
The string value=null appears in the response stream.
The string value=myAttributeValue appears in the response stream.