J2EE上机实报告.docVIP

  • 35
  • 0
  • 约1.65万字
  • 约 15页
  • 2016-10-06 发布于贵州
  • 举报
J2EE上机实报告

目录 J2EE上机实验报告 1 实验二、一个简单基于servlet的web应用程序 1 1、实验内容 1 2、关键代码 1 HelloWorld/web.xml 1 HelloWorld/HelloWorldServlet.java 1 3、实验结果截图 2 实验三、体验JSP转译阶段的规则 3 1、实验内容 3 2、关键代码 3 Trans/index.jsp 3 Trans/trainsformain.jsp 3 Trans/error.jsp 5 Trans/included.jsp 6 Trans/causeError.jsp 7 3、实验结果截图 7 实验四、JavaBean和数据库元数据编程 8 1、实验内容 8 2、关键代码 9 testJDBC/connectDB.java 9 testJDBC/database.jsp 11 3、实验结果截图 13 实验体会 13 J2EE上机实验报告 实验二、一个简单基于servlet的web应用程序 1、实验内容 创建第一个web应用程序HelloWorld,包含一个servlet名为“HelloWorldServlet”,为该servlet设置二个初始化参数,参数名分别为name和student_no,参数值分别为“学生姓名”和“学号”(每个同学使用自己的姓名和学号)。运行该servlet,输出格式为 学号为*********的***同学,你好! 这是一个简单的servlet程序 2、关键代码 HelloWorld/web.xml …… init-param param-namename/param-name param-value侍路登/param-value /init-param init-param param-namestudent_no/param-name param-value0706550124/param-value /init-param HelloWorld/HelloWorldServlet.java …… String name, student_no; …… /** * The doGet method of the servlet. br * * 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 { response.setContentType(text/html); response.setCharacterEncoding(utf-8); PrintWriter out = response.getWriter(); out.println(!DOCTYPE HTML PUBLIC \-//W3C//DTD HTML 4.01 Transitional//EN\); out.println(HTML); out.println( HEADTITLEA Servlet/TITLE/HEAD); out.println( BODY); out.print(学号为 + student_no + 的 + name + 同学,你好!); out.print(br); out.print(这是一个简单的servlet程序); out.println( /BODY); out.println(/HTML); out.flush(); out.close(); } …… /** * Initialization of the servlet. br * * @throws ServletException if an error occurs */ public void init() th

文档评论(0)

1亿VIP精品文档

相关文档