网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

给定一个Servlet程序的代码片段,如下: Public void doPost(HttpServletRequestrequest,HttpServletResponse response) throws ServletException { request.getSession().getAttribute(“A”); //第二行 } 假定第二行返回的对象引用不是null,那么这个对象存储在()范围中

A.page

B.session

C.request

D.application


参考答案和解析
session
更多 “给定一个Servlet程序的代码片段,如下: Public void doPost(HttpServletRequestrequest,HttpServletResponse response) throws ServletException { request.getSession().getAttribute(“A”); //第二行 } 假定第二行返回的对象引用不是null,那么这个对象存储在()范围中A.pageB.sessionC.requestD.application” 相关考题
考题 在J2EE中,在Servlet1中的doGet和doPost方法中只有如下代码:request.setAttribute(jb,aptech);response.sendRedirect(http://localhost:8080/servlet/Servlet2);那么在Servlet2中使用()可以把属性jb的值取出来。 A.Stringstr=request.getAttribute(jb);B.Stringstr=(String)request.getAttribute(jb);C.Objectstr=request.getAttribute(jb);D.取不出来

考题 在J2EE中,给定某Servlet的代码如下,编译运行该文件,以下陈述正确的是( )public class Servletl extends HttpServlet{public void init() throws ServletException{}public void service(HttpServletRequestrequest,HttpServletResponse response)throwsServletException,IOException{PrintWriter ut=response.getWriter();out.println(“hello!”);}}A、编译该文件时会提示缺少doGet()或者doPost()方法,编译不能够成功通过B、编译后,把Servletl.class放在正确位置,运行该Servlet,在浏览器中会看到输出文字:hello!C、编译后,把Servletl.class放在正确位置,运行该Servlet,在浏览器中会看不到任何输出的文字D、编译后, 把Servletl.class放在正确位置,运行该Servlet,在浏览器中会看到运行期错误信息

考题 给定某servlet 程序的片段,如下:Public void doGet(HttpServletRequestrequest,Httpservletresponse response){_________}要把session的失效时间设为30分钟,应该在下划线处插入( )A、request.getSession().setTimeout(1800);B、request.getSession().setTimeout(30)C、request.getSession().setMaxInactiveInterval(1800);D、request.getSession().setMaxInactiveInterval(30);

考题 给定一个自定义标签程序的代码片断如下:public int doStartTage() throws JspTagException{pageContext.getAttribute(“A”); //第二行return EVAL_BODY_INCLUDE;}假定第二行返回的对象引用不是null,那么这个对象存储在( )范围中A、pageB、sessionC、requestD、application

考题 给出下列的程序段,哪个选项是不正确的? ( ) ①public void create(){ ②Vector my; ③my=new Vector(); ④}A.第二行的声明不会为变量my分配内存空间B.第二行语句创建一个Vector类对象C.第三行语句创建一个Vector类对象D.第三行语句为一个Vector类对象分配内存空间

考题 给出下列的程序代码片段,下列的( )选项是不正确的。 ①public void create(){ ②Vector my; ⑧my=new Vector(); ④}A.第二行的声明不会为变量my分配内存空间B.第二行语句创建一个Vector类对象C.第三行语句创建一个Vector类对象D.第三行语句为一个Vector类对象分配内存空间

考题 把一个对象写到一个流中相对比较简单,具体是通过调用ObjectOutputStream类的writeObject()方法实现的,那么该方法的定义为( )。A.public final int writeObject(Object obj) throws IOExceptionB.public final void writeObject(Object obj) throws IOExceptionC.public Object writeObject(Object obj) throws IOExceptionD.public final Object writeObject(Object obj) throws IOException

考题 读下列说明和Java代码,将应填入(n)处的字句写在对应栏内。【说明】已知某类库开发商捉供了一套类库,类库中定义了Application类和Document类,它们之间的关系如下图所示,其中,Application类表示应用程序自身,而Document类则表示应用程序打开的文档。Application类负责打开一个已有的以外部形式存储的文档,如一个文件,一旦从该文件中读出信息后,它就由一个Document对象表示。当开发一个具体的应用程序时,开发者需要分别创建自己的Application和Document子类,例如上图中的类MyApplication和类MyDocument,并分别实现Application和 Document类中的某些方法。已知Application类中的openDocument方法采用了模板方法(Template Method)设计模式,该方法定义了打开文档的每一个主要步骤,如下所示:1.首先检查文档是否能够被打开,若不能打开,则给出出错信息并返回;2.创建文档对象;3.通过文档对象打开文档;4.通过文档对象读取文档信息;5.将文档对象加入到Application的文档对象集合中。【Java代码】abstract class Document{public void save(){/*存储文档数据,此处代码省略*/ )public void open(String docName){ /*打开文档,此处代码省略*/)public void close(){ /*关闭文档,此处代码省略*/)public abstract void read(String docName);};abstract class Appplication{private Vector<(1)> docs; /*文档对象集合*/public boolean canOpenDocument(String docName){/*判断是否可以打开指定文档,返回真值时表示可以打开,返回假值表示不可打开,此处代码省略*/}public void addDocument(Document aDocument){/*将文档对象添加到文档对象集合中*/docs.add((2));}public abstract Document doCreateDocument();/*创建一个文档对象*/public void openDocument(String docName){/*打开文档*/if ((3)) {System.out.println(“文档无法打开!”);return;}(4) adoc=(5);(6);(7);(8);}};

考题 给出下列的程序代码片段,下列选项说法不正确的是( )。 ① public void create( ){ ② Vector my; ③ my = new Vector( ); ④ }A.第二行的声明不会为变量my分配内存空间B.第二行语句创建一个Vector类对象C.第三行语句创建一个Vector类对象D.第三行语句为一个Vector类对象分配内存空间

考题 Servlet的基本架构public class ServletName extends HttpServlet {public void doPost(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {}public void doGet(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {}}1、用String的方法将数据类型转换为String。

考题 下面的代码中方法unsafe()有异常发生,那么可以加在第一行的语句为( )。 { if(unsafe()) { //do something } else if(safe()) { //do the other) } Ⅰ:public void methodName() Ⅱ:public void methodName() throw IOException Ⅲ:public void methodName() throws IOException Ⅳ:public void methodName() throws ExceptionA.Ⅲ、ⅣB.Ⅱ、Ⅲ、ⅣC.Ⅰ、ⅢD.Ⅰ、Ⅳ

考题 下面哪个方法不是HttpServlet类:()A、protected void doGet(HttpServletRequest reg,HttpServletResponse res) throws Servlet Exception ,java.io.IOExceptionB、protected void doPost(HttpServletRequest reg,HttpServletResponse res) throws Servlet Exception,java.io.IOExceptionC、protected void doHead(HttpServletRequest reg,HttpServletResponse res) throws Servlet Exception,java.io.IOExceptionD、protected void doReceive(HttpServletRequest reg,HttpServletResponse res) throws ServletException,java.io.IOException

考题 在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 () throw ServletException {}   Public void service(HttpServletRequest request,  HttpServletResponce response) throws ServletException,IOException{  PrintWriter out=response.getWriter();   Out.println(“hello!”); } }  假如编译Servlet要具备的环境都已经建立好。现在用完全正确的命令编译该文件,对于以下成熟正确的是()  A、编译该晚间时会提示缺少doGe()t或者doPost(),编译不能够成功通过B、编译后,把Serlvet.cass放在正确的位置,在浏览器中查看该Servlet1,会看到输出文在:“hello!”C、编译后,把Servlet.class放在正确的位置,在浏览器中查看该Servlet1,却看不到任何输出的文字D、编译后,把Servlet.class放在正确的位置,在浏览器中查看该Servlet1,却看到产生运行时错误的出错信息

考题 在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要具备的环境都已经建立好。现在用完全正确的命令编译该文件,对于以下陈述正确的是()。 A、编译该文件时会提示缺少doGet()或者doPost()方法,编译不能够成功通过B、编译后,把Servlet1.class放在正确位置,在浏览器中查看该Servlet1,会看到输出文字:“hello!”C、编译后,把Servlet1.class放在正确位置,在浏览器中查看该Servlet1,却看不到任何输出的文字D、编译后,把Servlet1.class放在正确位置,在浏览器中查看该Servlet1,却看到产生运行时错误的出错信息

考题 在J2EE中,Servlet1的代码如下:  import javax.servlet.*;  import javax.servlet.http.*; import java.io.*;  public class Servlet1 extends HttpServlet {  public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {      response.setContentType("text/html");      PrintWriter out = response.getWriter();      String aa=request.getQueryString();      String bb=request.getMethod();      out.println(aa);  out.println(bb);   } }  把Servlet1.class文件放在Web服务器适合的目录下,在浏览B器地址栏内输入:http://localhost:8080/servlet/Servlet1?name=jb-aptechphone=12345678,看到的结果是()。 A、name=jb-aptechphone=12345678 GETB、name=jb-aptech,phone=12345678 GETC、jb-aptech,12345678 POSTD、name,phone GETE、2,POST

考题 在Servlet中,response.getWriter()返回的是()。A、JspWriter对象B、PrintWriter对象C、Out对象D、ResponseWriter对象

考题 在j2ee中,有如下代码在servlet1.java中  Important javax.servelt.*;  Important javax.servlet.http.*  Import java.io.ioexception  Import java.io.printwriter  Public class servlet1 extends httpservlet{  Public void init() throws serveltexception{ }  Public void service(httpservelt request request,httpserbletresponse response)throws servletexception,ioexception{   Printwriter out=response.getwriter();   Out.println(“hello”); } }  假如编译serblet 要具备的环境都已经建立好,现在用完全正确的命令编译该文件,对于以下陈述正确的是() A、编译该文件时会提示缺少doget()或者dopost()方法,编译不能够成功通过B、编译后,把servlet1.class放在正确位置,在浏览器中查看该servlet1,会看到输出文字:“hello”C、编译后,把servlet1.class放在正确位置,在浏览器中查看该servlet1,却看不到任何输出的文字D、编译后,把servlet1.class放在正确位置,在浏览器中查看该servlet1,却看到产生运行时错误的出差信息

考题 在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 = reponse.getWriter(); Out.println("hello!"); } }  假如要编  译的环境已都已经搭建好。现在用完全正确的命令编译该文件,对于以下陈述正确的是(); A、编译文件时会提醒缺少doGet和doPost方法,编译不能成功通过B、编译后,把Servlet.Class放在正确的位置,在浏览器查看该Servlet会看到输出文字:“hello”C、编译后,把Servlet.Class放在正确的位置,在浏览器查看该Servlet却看不到任何文字D、编译后,把Servlet.Class放在正确的位置,在浏览器查看该Servlet会却看到运行时的错误信息

考题 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: 302 /html/error.html Which,inserted at line 15,causes the container to redirect control to the error.html resource?()A、response.setError(302);B、response.sendError(302);C、response.setStatus(302);D、response.sendRedirect(302);E、response.sendErrorRedirect(302);

考题 单选题在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 () throw ServletException {}   Public void service(HttpServletRequest request,  HttpServletResponce response) throws ServletException,IOException{  PrintWriter out=response.getWriter();   Out.println(“hello!”); } }  假如编译Servlet要具备的环境都已经建立好。现在用完全正确的命令编译该文件,对于以下成熟正确的是()A 编译该晚间时会提示缺少doGe()t或者doPost(),编译不能够成功通过B 编译后,把Serlvet.cass放在正确的位置,在浏览器中查看该Servlet1,会看到输出文在:“hello!”C 编译后,把Servlet.class放在正确的位置,在浏览器中查看该Servlet1,却看不到任何输出的文字D 编译后,把Servlet.class放在正确的位置,在浏览器中查看该Servlet1,却看到产生运行时错误的出错信息

考题 单选题在j2ee中,有如下代码在servlet1.java中  Important javax.servelt.*;  Important javax.servlet.http.*  Import java.io.ioexception  Import java.io.printwriter  Public class servlet1 extends httpservlet{  Public void init() throws serveltexception{ }  Public void service(httpservelt request request,httpserbletresponse response)throws servletexception,ioexception{   Printwriter out=response.getwriter();   Out.println(“hello”); } }  假如编译serblet 要具备的环境都已经建立好,现在用完全正确的命令编译该文件,对于以下陈述正确的是()A 编译该文件时会提示缺少doget()或者dopost()方法,编译不能够成功通过B 编译后,把servlet1.class放在正确位置,在浏览器中查看该servlet1,会看到输出文字:“hello”C 编译后,把servlet1.class放在正确位置,在浏览器中查看该servlet1,却看不到任何输出的文字D 编译后,把servlet1.class放在正确位置,在浏览器中查看该servlet1,却看到产生运行时错误的出差信息

考题 单选题在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要具备的环境都已经建立好。现在用完全正确的命令编译该文件,对于以下陈述正确的是()。A 编译该文件时会提示缺少doGet()或者doPost()方法,编译不能够成功通过B 编译后,把Servlet1.class放在正确位置,在浏览器中查看该Servlet1,会看到输出文字:“hello!”C 编译后,把Servlet1.class放在正确位置,在浏览器中查看该Servlet1,却看不到任何输出的文字D 编译后,把Servlet1.class放在正确位置,在浏览器中查看该Servlet1,却看到产生运行时错误的出错信息

考题 单选题在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 = reponse.getWriter(); Out.println("hello!"); } }  假如要编  译的环境已都已经搭建好。现在用完全正确的命令编译该文件,对于以下陈述正确的是();A 编译文件时会提醒缺少doGet和doPost方法,编译不能成功通过B 编译后,把Servlet.Class放在正确的位置,在浏览器查看该Servlet会看到输出文字:“hello”C 编译后,把Servlet.Class放在正确的位置,在浏览器查看该Servlet却看不到任何文字D 编译后,把Servlet.Class放在正确的位置,在浏览器查看该Servlet会却看到运行时的错误信息

考题 多选题你为TestKing创建一个用来显示销售分析信息的ASP.NET应用程序。一个名为SalesSummary.aspx的页面显示了三个分离的信息片。你为每个片段编写代码来调用数据库中的存储过程。每个片段的代码调用不同的存储过程。在存储过程运行之后,结果马上写成HTML格式给应用程序的Response对象。你不想让用户在开始收到呈现在他们的浏览器上的内容之前等待,直到结果从三个存储过程返回。哪两个可能的方法可以达到这个目的?()A设置Response对象的SuppressContent属性为FalseB设置Response对象的BufferOutput属性为FalseC设置Response对象的CacheControl属性值为PublicD在每部分都被写入该应用程序的Response对象后,插入下列代码:ResponsClear()E在每部分都被写入该应用程序的Response对象后,插入下列代码:ResponsClearContent()F在每部分都被写入该应用程序的Response对象后,插入下列代码:ResponsFlush()

考题 单选题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 here26. } 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?()A chain.forward(request, response);B chain.doFilter(request, response);C request.forward(request, response);D request.doFilter(request, response);

考题 单选题在J2EE中,在Servlet1中的doGet和doPost方法中只有如下代码:  request.setAttribute("jb","aptech");  response.sendRedirect("http://localhost:8080/servlet/Servlet2");  那么在Servlet2中使用()可以把属性jb的值取出来。A String str=request.getAttribute(jb);B String str=(String)request.getAttribute(jb);C Object str=request.getAttribute(jb);D 取不出来

考题 单选题在J2EE中,Servlet1的代码如下:  import javax.servlet.*;  import javax.servlet.http.*; import java.io.*;  public class Servlet1 extends HttpServlet {  public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {      response.setContentType("text/html");      PrintWriter out = response.getWriter();      String aa=request.getQueryString();      String bb=request.getMethod();      out.println(aa);  out.println(bb);   } }  把Servlet1.class文件放在Web服务器适合的目录下,在浏览B器地址栏内输入:http://localhost:8080/servlet/Servlet1?name=jb-aptechphone=12345678,看到的结果是()。A name=jb-aptechphone=12345678 GETB name=jb-aptech,phone=12345678 GETC jb-aptech,12345678 POSTD name,phone GETE 2,POST

考题 单选题Given the definition of MyServlet: 11.public class MyServlet extends HttpServlet { 12.public void service(HttpServletRequest request, 13.HttpServletResponse response) 14.throws ServletException, IOException { 15.HttpSession session = request.getSession(); 16.session.setAttribute("myAttribute","myAttributeValue"); 17.session.invalidate(); 18.response.getWriter().println("value=" + 19.session.getAttribute("myAttribute")); 20.} 21.} What is the result when a request is sent to MyServlet?()A An IllegalStateException is thrown at runtime.B An InvalidSessionException is thrown at runtime.C The string value=null appears in the response stream.D The string value=myAttributeValue appears in the response stream.