From 4178b3942f6812c3c93e4339416454cadb8b0c0f Mon Sep 17 00:00:00 2001 From: hy346143551 <346143551@qq.com> Date: Mon, 19 Dec 2016 10:52:24 +0800 Subject: [PATCH 1/7] #6 --- jweb/web/1414080902101/cilent.jsp | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 jweb/web/1414080902101/cilent.jsp diff --git a/jweb/web/1414080902101/cilent.jsp b/jweb/web/1414080902101/cilent.jsp new file mode 100644 index 00000000..30bc351b --- /dev/null +++ b/jweb/web/1414080902101/cilent.jsp @@ -0,0 +1,43 @@ +<%@ page language="java" contentType="text/html; charset=utf-8" + pageEncoding="utf-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + +Insert title here + + + + + + + +
+
+
+ +
+
+
+
+ + + +
+
+
+ + \ No newline at end of file From e2bb63c000df3f4fd112fa3d48ecc40ff4a41cd3 Mon Sep 17 00:00:00 2001 From: hy346143551 <346143551@qq.com> Date: Mon, 19 Dec 2016 11:14:04 +0800 Subject: [PATCH 2/7] #6 --- .../labs/Se1414080902101/JdbcConnect.java | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 jweb/src/edu/hzu/javaweb/labs/Se1414080902101/JdbcConnect.java diff --git a/jweb/src/edu/hzu/javaweb/labs/Se1414080902101/JdbcConnect.java b/jweb/src/edu/hzu/javaweb/labs/Se1414080902101/JdbcConnect.java new file mode 100644 index 00000000..ef8cb1b9 --- /dev/null +++ b/jweb/src/edu/hzu/javaweb/labs/Se1414080902101/JdbcConnect.java @@ -0,0 +1,75 @@ +package edu.hzu.javaweb.labs.se1414080902101; + +import java.sql.Connection; + import java.sql.DriverManager; + import java.sql.PreparedStatement; + import java.sql.ResultSet; + import java.sql.SQLException; + import java.util.ArrayList; + import java.util.List; + + public class JdbcConnect { + private static String url = "jdbc:mysql:///javaweb"; + private static String className = "com.mysql.jdbc.Driver"; + private static String user = "root"; + private static String password = "root"; + + private static Connection connect = null; + private static PreparedStatement statement = null; + private static ResultSet rs = null; + + public static Connection getConnection(){ + if(connect != null) + return connect; + try { + Class.forName(className); + connect = DriverManager.getConnection(url,user,password); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return connect; + } + + public static void closeConnection(){ + try { + connect.close(); + statement.close(); + rs.close(); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public List getUserinfo(){ + List userinfos = new ArrayList(); + Userinfo userinfo = null; + String sql = "select * from userinfo;"; + try { + connect = getConnection(); + statement = (PreparedStatement) connect.prepareStatement(sql); + rs = statement.executeQuery(); + if(rs != null){ + while(rs.next()){ + String id = rs.getString(0); + String name = rs.getString(1); + String date = rs.getString(2); + boolean sex = rs.getBoolean(3); + int age = rs.getInt(4); + userinfo = new Userinfo(id,name,date,sex,age); + userinfo.add(userinfo); + } + } + } catch (SQLException e) { + e.printStackTrace(); + }finally{ + closeConnection(); + } + return userinfos; + } + + } \ No newline at end of file From 18b4d0e9292e6b5b09eadd6e836894ffda73ce0a Mon Sep 17 00:00:00 2001 From: hy346143551 <346143551@qq.com> Date: Mon, 19 Dec 2016 11:26:10 +0800 Subject: [PATCH 3/7] #6 --- .../Se1414080902101Servlet.java | 91 ------------------- 1 file changed, 91 deletions(-) delete mode 100644 jweb/src/edu/hzu/javaweb/labs/Se1414080902101/Se1414080902101Servlet.java diff --git a/jweb/src/edu/hzu/javaweb/labs/Se1414080902101/Se1414080902101Servlet.java b/jweb/src/edu/hzu/javaweb/labs/Se1414080902101/Se1414080902101Servlet.java deleted file mode 100644 index ed15d567..00000000 --- a/jweb/src/edu/hzu/javaweb/labs/Se1414080902101/Se1414080902101Servlet.java +++ /dev/null @@ -1,91 +0,0 @@ -package se1414080902101; - -import java.io.IOException; -import java.io.PrintWriter; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -public class se1414080902101 extends HttpServlet { - - /** - * Constructor of the object. - */ - public se1414080902101() { - super(); - } - - /** - * Destruction of the servlet.
- */ - public void destroy() { - super.destroy(); // Just puts "destroy" string in log - // Put your code here - } - - /** - * The doGet method of the servlet.
- * - * 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"); - PrintWriter out = response.getWriter(); - out.println(""); - out.println(""); - out.println(" A Servlet"); - out.println(" "); - out.print(" This is "); - out.print(this.getClass()); - out.println(", using the GET method"); - out.println(" "); - out.println(""); - out.flush(); - out.close(); - } - - /** - * The doPost method of the servlet.
- * - * 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 { - - String userName=request.getParameter("username"); - String userPwd=request.getParameter("userpwd"); - String info=""; - if(("abc".equals(userName))&&"123".equals(userPwd)){ - info="ӭ"+userName+"!"; - }else{ - info="û벻ȷ"; - } - request.setAttribute("outputMessage",info); - request.getRequestDispatcher("info.jsp").forward(requset, response); - } - - - /** - * Initialization of the servlet.
- * - * @throws ServletException if an error occurs - */ - public void init() throws ServletException { - // Put your code here - } - -} From ef5f5df4c67921fe7f6469dd7c1b1c86a07f0038 Mon Sep 17 00:00:00 2001 From: hy346143551 <346143551@qq.com> Date: Mon, 19 Dec 2016 11:37:05 +0800 Subject: [PATCH 4/7] #6 --- jweb/web/1414080902101/{cilent.jsp => cuanche.jsp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename jweb/web/1414080902101/{cilent.jsp => cuanche.jsp} (100%) diff --git a/jweb/web/1414080902101/cilent.jsp b/jweb/web/1414080902101/cuanche.jsp similarity index 100% rename from jweb/web/1414080902101/cilent.jsp rename to jweb/web/1414080902101/cuanche.jsp From 7bcd1fb61da13d82a8ca83c3f3aaf27fa11f7803 Mon Sep 17 00:00:00 2001 From: hy346143551 <346143551@qq.com> Date: Mon, 19 Dec 2016 11:41:18 +0800 Subject: [PATCH 5/7] Delete cuanche.jsp --- jweb/web/1414080902101/cuanche.jsp | 43 ------------------------------ 1 file changed, 43 deletions(-) delete mode 100644 jweb/web/1414080902101/cuanche.jsp diff --git a/jweb/web/1414080902101/cuanche.jsp b/jweb/web/1414080902101/cuanche.jsp deleted file mode 100644 index 30bc351b..00000000 --- a/jweb/web/1414080902101/cuanche.jsp +++ /dev/null @@ -1,43 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=utf-8" - pageEncoding="utf-8"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> - - - -Insert title here - - - - - - - -
-
-
- -
-
-
-
- - - -
-
-
- - \ No newline at end of file From 285daa0dcb1984a6fbc34fa36bdbacc8ec46b7c2 Mon Sep 17 00:00:00 2001 From: hy346143551 <346143551@qq.com> Date: Fri, 23 Dec 2016 16:53:53 +0800 Subject: [PATCH 6/7] =?UTF-8?q?#6=20=E6=8F=90=E4=BA=A4=E5=AE=9E=E9=AA=8C?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../labs/Se1414080902101/JdbcConnect.java | 75 --------------- .../Se1414080902101Servlet.java | 91 +++++++++++++++++++ 2 files changed, 91 insertions(+), 75 deletions(-) delete mode 100644 jweb/src/edu/hzu/javaweb/labs/Se1414080902101/JdbcConnect.java create mode 100644 jweb/src/edu/hzu/javaweb/labs/Se1414080902101/Se1414080902101Servlet.java diff --git a/jweb/src/edu/hzu/javaweb/labs/Se1414080902101/JdbcConnect.java b/jweb/src/edu/hzu/javaweb/labs/Se1414080902101/JdbcConnect.java deleted file mode 100644 index ef8cb1b9..00000000 --- a/jweb/src/edu/hzu/javaweb/labs/Se1414080902101/JdbcConnect.java +++ /dev/null @@ -1,75 +0,0 @@ -package edu.hzu.javaweb.labs.se1414080902101; - -import java.sql.Connection; - import java.sql.DriverManager; - import java.sql.PreparedStatement; - import java.sql.ResultSet; - import java.sql.SQLException; - import java.util.ArrayList; - import java.util.List; - - public class JdbcConnect { - private static String url = "jdbc:mysql:///javaweb"; - private static String className = "com.mysql.jdbc.Driver"; - private static String user = "root"; - private static String password = "root"; - - private static Connection connect = null; - private static PreparedStatement statement = null; - private static ResultSet rs = null; - - public static Connection getConnection(){ - if(connect != null) - return connect; - try { - Class.forName(className); - connect = DriverManager.getConnection(url,user,password); - } catch (ClassNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (SQLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return connect; - } - - public static void closeConnection(){ - try { - connect.close(); - statement.close(); - rs.close(); - } catch (SQLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - public List getUserinfo(){ - List userinfos = new ArrayList(); - Userinfo userinfo = null; - String sql = "select * from userinfo;"; - try { - connect = getConnection(); - statement = (PreparedStatement) connect.prepareStatement(sql); - rs = statement.executeQuery(); - if(rs != null){ - while(rs.next()){ - String id = rs.getString(0); - String name = rs.getString(1); - String date = rs.getString(2); - boolean sex = rs.getBoolean(3); - int age = rs.getInt(4); - userinfo = new Userinfo(id,name,date,sex,age); - userinfo.add(userinfo); - } - } - } catch (SQLException e) { - e.printStackTrace(); - }finally{ - closeConnection(); - } - return userinfos; - } - - } \ No newline at end of file diff --git a/jweb/src/edu/hzu/javaweb/labs/Se1414080902101/Se1414080902101Servlet.java b/jweb/src/edu/hzu/javaweb/labs/Se1414080902101/Se1414080902101Servlet.java new file mode 100644 index 00000000..ed15d567 --- /dev/null +++ b/jweb/src/edu/hzu/javaweb/labs/Se1414080902101/Se1414080902101Servlet.java @@ -0,0 +1,91 @@ +package se1414080902101; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class se1414080902101 extends HttpServlet { + + /** + * Constructor of the object. + */ + public se1414080902101() { + super(); + } + + /** + * Destruction of the servlet.
+ */ + public void destroy() { + super.destroy(); // Just puts "destroy" string in log + // Put your code here + } + + /** + * The doGet method of the servlet.
+ * + * 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"); + PrintWriter out = response.getWriter(); + out.println(""); + out.println(""); + out.println(" A Servlet"); + out.println(" "); + out.print(" This is "); + out.print(this.getClass()); + out.println(", using the GET method"); + out.println(" "); + out.println(""); + out.flush(); + out.close(); + } + + /** + * The doPost method of the servlet.
+ * + * 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 { + + String userName=request.getParameter("username"); + String userPwd=request.getParameter("userpwd"); + String info=""; + if(("abc".equals(userName))&&"123".equals(userPwd)){ + info="ӭ"+userName+"!"; + }else{ + info="û벻ȷ"; + } + request.setAttribute("outputMessage",info); + request.getRequestDispatcher("info.jsp").forward(requset, response); + } + + + /** + * Initialization of the servlet.
+ * + * @throws ServletException if an error occurs + */ + public void init() throws ServletException { + // Put your code here + } + +} From bbd32bb2d9d57a73771b5fa1d78c0d849ab95a10 Mon Sep 17 00:00:00 2001 From: hy346143551 <346143551@qq.com> Date: Fri, 23 Dec 2016 16:59:21 +0800 Subject: [PATCH 7/7] =?UTF-8?q?#7=20=E6=8F=90=E4=BA=A4=E5=AE=9E=E9=AA=8C?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../labs/Se1414080902101/JdbcConnect.java | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 jweb/src/edu/hzu/javaweb/labs/Se1414080902101/JdbcConnect.java diff --git a/jweb/src/edu/hzu/javaweb/labs/Se1414080902101/JdbcConnect.java b/jweb/src/edu/hzu/javaweb/labs/Se1414080902101/JdbcConnect.java new file mode 100644 index 00000000..ef8cb1b9 --- /dev/null +++ b/jweb/src/edu/hzu/javaweb/labs/Se1414080902101/JdbcConnect.java @@ -0,0 +1,75 @@ +package edu.hzu.javaweb.labs.se1414080902101; + +import java.sql.Connection; + import java.sql.DriverManager; + import java.sql.PreparedStatement; + import java.sql.ResultSet; + import java.sql.SQLException; + import java.util.ArrayList; + import java.util.List; + + public class JdbcConnect { + private static String url = "jdbc:mysql:///javaweb"; + private static String className = "com.mysql.jdbc.Driver"; + private static String user = "root"; + private static String password = "root"; + + private static Connection connect = null; + private static PreparedStatement statement = null; + private static ResultSet rs = null; + + public static Connection getConnection(){ + if(connect != null) + return connect; + try { + Class.forName(className); + connect = DriverManager.getConnection(url,user,password); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return connect; + } + + public static void closeConnection(){ + try { + connect.close(); + statement.close(); + rs.close(); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public List getUserinfo(){ + List userinfos = new ArrayList(); + Userinfo userinfo = null; + String sql = "select * from userinfo;"; + try { + connect = getConnection(); + statement = (PreparedStatement) connect.prepareStatement(sql); + rs = statement.executeQuery(); + if(rs != null){ + while(rs.next()){ + String id = rs.getString(0); + String name = rs.getString(1); + String date = rs.getString(2); + boolean sex = rs.getBoolean(3); + int age = rs.getInt(4); + userinfo = new Userinfo(id,name,date,sex,age); + userinfo.add(userinfo); + } + } + } catch (SQLException e) { + e.printStackTrace(); + }finally{ + closeConnection(); + } + return userinfos; + } + + } \ No newline at end of file