PublicclassServlet1extendsHttpServlet{
Publicvoidinit()throwsServletException{
}
Publicvoidservice(HttpServletRequestrequest,HttpServletResponseresponse)
ThrowsServletException,IOException{
PrintWriterout=response.getWriter();
out.println(“hello!”);
}}
举一反三
- 在J2EE中,给定某Servlet的代码如下,编译运行该文件,以下陈述正确的是() Public class Servlet1 extends HttpServlet{ Publicvoid init() throws ServletException{ } Publicvoid service(HttpServletRequest request,HttpServletResponse response) ThrowsServletException,IOException{ PrintWriterout = response.getWriter(); out.println(“hello!”); }}
- 在Servlet中有一段代码如下 public void doPost(HttpServletRequestrequest, HttpServletResponse response) throwsServletException, IOException { request.setAttribute("name
- 在J2EE中,给定某Servlet的代码如下,编译运行该文件,以下陈述正确的是(...rintln(“hello!”);}}
- 在Servlet中有一段代码如下 publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse) throwsServletException,IOException{ request.setAttribute("name",newInteger(100)); response.sendRedirect("show.jsp"); } 在show.jsp中 <%=request.getAttribute("name")%> 页面结果为
- 给定某Servlet的代码如下: Public class Servlet1 extends HttpServlet{ Public void init() throws ServletException{ } Public void service(HttpServletRequest request,HttpServletResponse response) ThrowsServletException,IOException{ PrintWriter out = response.getWriter(); <br/>out.println(“hello!”); }} 编译运行该文件,以下陈述正确的是()。 A: 编译该文件时会提示缺少doGet()或者dopost()方法,编译不能够成功通过 B: 编译后,把Servlet1.class放在正确位置,运行该Servlet,在浏览器中会看到输出文字: C: 编译后,把Servlet1.class放在正确位置,运行该Servlet,在浏览器中看不到任何输出 D: 编译后,把Servlet1.class放在正确位置,运行该Servlet,在浏览器中会看到运行期错误
内容
- 0
在Servlet中有一段代码如下 public void doPost(HttpServletRequestrequest, HttpServletResponse response) throwsServletException, IOException { request.setAttribute("name", new Integer(100)); response.sendRedirect("show.jsp"); } 在show.jsp中 <%=request.getAttribute("name")%> 页面结果为
- 1
在Servlet中有一段代码如下 public void doPost(HttpServletRequestrequest, HttpServletResponse response)throwsServletException, IOException { request.setAttribute("name", new Integer(100)); response.sendRedirect("show.jsp"); } 在show.jsp中 页面结果为( ) A: 100 B: java.lang.Intege C: Intege D:
- 2
中国大学MOOC:publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{request.getSession().getAttribute(“A”);//第二行}假定第二行返回的对象引用不是null,那么这个对象存储在()范围中。
- 3
给定一个Servlet的代码片段如下: Public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{ ______ out.println("hi kitty! "); out.close(); } 运行Servlet时输出:hi kitty! 则应在此Servlet下划线处填充如下代码
- 4
阅读下列的代码 public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException{ out.println("hello kity!"); } 若使Servlet运行的结果为hi kitty!,填写在空白处的代码为() 则应在此Servlet下划线处添加如下()代码