北京工业大学软件学院本科生j2ee与中间件技术考试模拟试题_-_评分标准及参考答案内容摘要:

得分 分 未答、或答案明显错误,得分 0 分 第 11 页 共 29 页 四、 J2EE 程序设计和程序阅读题题 ( 20 分) 1 ( 5 分) 编写包含 servlet 基本架构 的程序,实现输出 “ This is m y servlet demo!”, 要求:必须实现 Servlet 生命周期的各种方法的调用过程; 1 实施 Servlet API 导入 import。 import。 import。 import。 import。 import。 2 表示和实现 MyServlet 类 public class MyServlet extends HttpServlet { /** * Constructor of the object. */ public MyServlet() { super()。 } 3 表示和实施 init()和 destroy() 方法 /** * Destruction of the servlet. br */ public void destroy() { ()。 // Just puts destroy string in log // Put your code here } 4 表示和实施 doGet 方法 /** * The doGet method of the servlet. br * 得 分 第 12 页 共 29 页 * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { (text/html)。 PrintWriter out = ()。 (!DOCTYPE HTML PUBLIC \//W3C//DTD HTML Transitional//EN\)。 (HTML)。 ( HEADTITLEA Servlet/TITLE/HEAD)。 ( BODY)。 ( This is my servlet demo!)。 (())。 (, using the GET method)。 ( /BODY)。 (/HTML)。 ()。 ()。 } 5 表示和实施 doPost()方法内容 /** * The doPost method of the servlet. br * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { (text/html)。 PrintWriter out = ()。 第 13 页 共 29 页 (!DOCTYPE HTML PUBLIC \//W3C//DTD HTML Transitional//EN\)。 (HTML)。 ( HEADTITLEA Servlet/TITLE/HEAD)。 ( BODY)。 ( This is my servlet demo!)。 (())。 (, using the POST method)。 ( /BODY)。 (/HTML)。 ()。 ()。 } /** * Initialization of the servlet. br * * @throws ServletException if an error occurs */ public void init() throws ServletException { // Put your code here } } 评分标准: 1 能表示和描述 Servlet 导入对象得 分; 2 能表示和实施 MyServlet 类, 得 1 分; 3 能表示和实施 init()、 destroy 类方法内容, 得 1 分; 4 能表示 和实施 doGet 方法内容, 得 1 分; 5 能表示和实施 doPost() 方法内容, 得 1 分 在每一步骤内容, 不符合标准答案,但答题的内容在内容表达上符合要求, 得分 分 未答、或答案明显错误,得分 0 分 2 ( 5 分) 写一个 JSP 的程序,用它来计算 整数 1, 2, 3, … .100 的和 1 表示和实施 JSP 方法 %@ page language=java import=.* pageEncoding=GB18030% 第 14 页 共 29 页 HTML BODY BGCOLOR=cyan FONT Size=1 P This is My JSP Page for /P 2 表示和实施 java 程序块 % int i, sum=0。 for(i=1。 i=100。 i++){ sum=sum+i。 } % P 1 到 100 的连续和是: /P BR 3 表示和实施计算结果 %= sum % /FONT /BODY HTML 评分标准: 1 能表示和描述 JSP 导入对象得 1 分; 2 能表示和实施 Java 程序段, 得 2 分; 3 能表示和实施计算结果方 法内容, 得 2 分; 在每一步骤内容, 不符合标准答案,但答题的内容在内容表达上符合要求, 得分 分 未答、或答案明显错误,得分 0 分 3( 5 分) 写 出下面 JSP 程序的运行结果 %@ page language=java import=.* pageEncoding=GB18030% 第 15 页 共 29 页 !DOCTYPE HTML PUBLIC //W3C//DTD HTML Transitional//EN html headtitle JSP Code Page /title/head body This is a jsp exam_code page. hr br %! int i, j。 % %! int a=5, b=10。 double c=。 % % for(i = 0。 i =10。 i++) { for (j=0。 j = i。 j++) { % %= j %。 % } % br % } % br a+b = %= a+b % br 半径为 %= c % 的圆面积是: %= *(c,2) % /body /html 1 JSP 中 HTML 执行结果 This is a jsp exam_code page. 2 能表示和实施 Java 程序段 0。 0。 1。 第 16 页 共 29 页 0。 1。 2。 0。 1。 2。 3。 0。 1。 2。 3。 4。 0。 1。 2。 3。 4。 5。 0。 1。 2。 3。 4。 5。 6。 0。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。