在J2EE中,给定某Servlet的代码如下,编译运行该文件,以下陈述正确的是
PublicclassServlet1extendsHttpServlet{
Publicvoidinit()throwsServletException{
}
Publicvoidservice(HttpServletRequestrequest,HttpServletResponseresponse)
ThrowsServletException,IOException{
PrintWriterout=response.getWriter();
out.println(“hello!”);
}}
PublicclassServlet1extendsHttpServlet{
Publicvoidinit()throwsServletException{
}
Publicvoidservice(HttpServletRequestrequest,HttpServletResponseresponse)
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,在浏览器中会看到运行期错误
- 在Servlet中有一段代码如下 public void doPost(HttpServletRequestrequest, HttpServletResponse response) throwsServletException, IOException { request.setAttribute("name", new Integer(100)); response.sendRedirect("show.jsp"); } 在show.jsp中 <%=request.getAttribute("name")%> 页面结果为