3 doGet() 和 doPost() 的区别?
在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中,对于HttpServlet类的描述,正确的是()。A.我们自己编写的Servlet继承了HttpServlet类,一般只需覆盖doPost或者doGet方法,不必覆盖service()方法。因为一个service()方法是空的B.HttpServlet类扩展了GenericServlet类,实现了GenericServlet类的抽象方法service()C.HttpServlet类有两个service()方法D.我们自己编写的Servlet继承了HttpServlet类,一般只需覆盖doPost或者doGet方法,不必覆盖service()方法。因为一个service()方法会调用doPost或者doGet方法
开发JavaWeb应用程序时,创建一个Servlet,该Servlet重写了其父类的doGet()和doPost()方法,那么其父类可能有( )A、GenericServletB、ServletResponseC、ServletRequestD、HttpServlet
下面哪项不是Servlet处理客户请求的方法()A、doPost()B、doGet()C、service()D、destroy()
什么情况下调用doGet()和doPost()?
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。
下面关于Servlet生命周期,说法不正确的是()。 A、 在创建自己的Servlet时候,应该在初始化方法init()方法中创建Servlet实例B、 在Servlet生命周期的服务阶段,执行service()方法,根据用户请求的方法,执行相应的doGet()或是doPost()方法C、 在销毁阶段,执行destroy()方法后系统立刻进行垃圾回收D、 destroy()方法仅执行一次