diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..2a97be5
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 0000000..7a85114
--- /dev/null
+++ b/.project
@@ -0,0 +1,36 @@
+
+
+ change_book_server
+
+
+
+
+
+ org.eclipse.wst.jsdt.core.javascriptValidator
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.wst.common.project.facet.core.builder
+
+
+
+
+ org.eclipse.wst.validation.validationbuilder
+
+
+
+
+
+ org.eclipse.jem.workbench.JavaEMFNature
+ org.eclipse.wst.common.modulecore.ModuleCoreNature
+ org.eclipse.wst.common.project.facet.core.nature
+ org.eclipse.jdt.core.javanature
+ org.eclipse.wst.jsdt.core.jsNature
+
+
diff --git a/.settings/.jsdtscope b/.settings/.jsdtscope
new file mode 100644
index 0000000..3a28de0
--- /dev/null
+++ b/.settings/.jsdtscope
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..f42de36
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component
new file mode 100644
index 0000000..a042f67
--- /dev/null
+++ b/.settings/org.eclipse.wst.common.component
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 0000000..b3f07fe
--- /dev/null
+++ b/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.container b/.settings/org.eclipse.wst.jsdt.ui.superType.container
new file mode 100644
index 0000000..3bd5d0a
--- /dev/null
+++ b/.settings/org.eclipse.wst.jsdt.ui.superType.container
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.name b/.settings/org.eclipse.wst.jsdt.ui.superType.name
new file mode 100644
index 0000000..05bd71b
--- /dev/null
+++ b/.settings/org.eclipse.wst.jsdt.ui.superType.name
@@ -0,0 +1 @@
+Window
\ No newline at end of file
diff --git a/WebContent/META-INF/MANIFEST.MF b/WebContent/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..254272e
--- /dev/null
+++ b/WebContent/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
diff --git a/WebContent/WEB-INF/lib/commons-codec-1.8.jar b/WebContent/WEB-INF/lib/commons-codec-1.8.jar
new file mode 100644
index 0000000..32f84c9
Binary files /dev/null and b/WebContent/WEB-INF/lib/commons-codec-1.8.jar differ
diff --git a/WebContent/WEB-INF/lib/mysql-connector-java-5.1.26-bin.jar b/WebContent/WEB-INF/lib/mysql-connector-java-5.1.26-bin.jar
new file mode 100644
index 0000000..bf1e933
Binary files /dev/null and b/WebContent/WEB-INF/lib/mysql-connector-java-5.1.26-bin.jar differ
diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml
new file mode 100644
index 0000000..77b2d03
--- /dev/null
+++ b/WebContent/WEB-INF/web.xml
@@ -0,0 +1,98 @@
+
+
+ change_book_server
+
+
+ PushMessage
+ com.touch.graduation.servlet.PushMessageServlet
+
+
+
+ PushMessage
+ /pushMessage
+
+
+
+ Login
+ com.touch.graduation.servlet.LoginServlet
+
+
+
+ Login
+ /login
+
+
+
+ Register
+ com.touch.graduation.servlet.RegisterServlet
+
+
+
+ Register
+ /register
+
+
+
+ GetMessage
+ com.touch.graduation.servlet.GetMessageServlet
+
+
+
+ GetMessage
+ /getMessage
+
+
+
+ GetAccountIntroduce
+ com.touch.graduation.servlet.GetAccountIntroduceServlet
+
+
+
+ GetAccountIntroduce
+ /getAccountIntroduce
+
+
+
+ SetAccountIntroduce
+ com.touch.graduation.servlet.SetAccountIntroduceServlet
+
+
+
+ SetAccountIntroduce
+ /setAccountIntroduce
+
+
+
+ GetPublishedMessage
+ com.touch.graduation.servlet.GetPublishedMessageSetvlet
+
+
+
+ GetPublishedMessage
+ /getPublishedMessage
+
+
+
+ RemoveBookFromBookToChangedBook
+ com.touch.graduation.servlet.RemoveBookFromBookToChangedBookServlet
+
+
+
+ RemoveBookFromBookToChangedBook
+ /removeBookFromBookToChangedBook
+
+
+
+ GetGivedBookMessage
+ com.touch.graduation.servlet.GetGivedBookMessageServlet
+
+
+
+ GetGivedBookMessage
+ /getGivedBookMessage
+
+
+
\ No newline at end of file
diff --git a/WebContent/images/bg.png b/WebContent/images/bg.png
new file mode 100644
index 0000000..e348fb6
Binary files /dev/null and b/WebContent/images/bg.png differ
diff --git a/WebContent/index.jsp b/WebContent/index.jsp
new file mode 100644
index 0000000..c2e8c63
--- /dev/null
+++ b/WebContent/index.jsp
@@ -0,0 +1,48 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+
+
+
+
+服务器
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WebContent/style/wall.css b/WebContent/style/wall.css
new file mode 100644
index 0000000..b1fced4
--- /dev/null
+++ b/WebContent/style/wall.css
@@ -0,0 +1,72 @@
+body {
+ background: url("../images/bg.png");
+}
+
+/* #main2 {
+ margin: auto;
+ padding-top: 10px;
+ padding-left: 23%;
+ width: 72%;
+ float: left;
+} */
+
+#main {
+ text-align: center; width : 100%;
+ //background: #FFFFCC;
+ width: 100%;
+}
+
+#main ul li {
+ text-align: center;
+ font-size: 25px;
+ display: inline;
+ width: 50px;
+ line-height: 50px;
+ text-shadow: 0 1px 1px rgba(0, 0, 0, .2);
+ padding: 15px;
+}
+
+#main a:link {
+ text-decoration: none;
+ color: blue
+}
+
+#main a:active {
+ text-decoration: blink
+}
+
+#main a:hover {
+ text-decoration: underline;
+ color: red
+}
+
+#main a:visited {
+ text-decoration: none;
+ color: green
+}
+
+.content {
+ width: 600px;
+ height: auto;
+ font-size: 16px;
+ font-family: "微软雅黑";
+}
+
+.time {
+ width: 300px;
+ height: 20px;
+ font-size: 16px;
+}
+
+.rub {
+ height: auto;
+ min-width: 20px;
+}
+
+#logoff {
+ width: 50px;
+ float: right;
+}
+#myclock{
+ text-align: center;
+}
\ No newline at end of file
diff --git a/build/classes/com/touch/graduation/common/Book.class b/build/classes/com/touch/graduation/common/Book.class
new file mode 100644
index 0000000..ee37b67
Binary files /dev/null and b/build/classes/com/touch/graduation/common/Book.class differ
diff --git a/build/classes/com/touch/graduation/database/ConnectDatabase.class b/build/classes/com/touch/graduation/database/ConnectDatabase.class
new file mode 100644
index 0000000..dadc567
Binary files /dev/null and b/build/classes/com/touch/graduation/database/ConnectDatabase.class differ
diff --git a/build/classes/com/touch/graduation/database/OperateDatabase.class b/build/classes/com/touch/graduation/database/OperateDatabase.class
new file mode 100644
index 0000000..26926c8
Binary files /dev/null and b/build/classes/com/touch/graduation/database/OperateDatabase.class differ
diff --git a/build/classes/com/touch/graduation/servlet/GetAccountIntroduceServlet.class b/build/classes/com/touch/graduation/servlet/GetAccountIntroduceServlet.class
new file mode 100644
index 0000000..6ab1917
Binary files /dev/null and b/build/classes/com/touch/graduation/servlet/GetAccountIntroduceServlet.class differ
diff --git a/build/classes/com/touch/graduation/servlet/GetGivedBookMessageServlet.class b/build/classes/com/touch/graduation/servlet/GetGivedBookMessageServlet.class
new file mode 100644
index 0000000..e464224
Binary files /dev/null and b/build/classes/com/touch/graduation/servlet/GetGivedBookMessageServlet.class differ
diff --git a/build/classes/com/touch/graduation/servlet/GetMessageServlet.class b/build/classes/com/touch/graduation/servlet/GetMessageServlet.class
new file mode 100644
index 0000000..160ced2
Binary files /dev/null and b/build/classes/com/touch/graduation/servlet/GetMessageServlet.class differ
diff --git a/build/classes/com/touch/graduation/servlet/GetPublishedMessageSetvlet.class b/build/classes/com/touch/graduation/servlet/GetPublishedMessageSetvlet.class
new file mode 100644
index 0000000..f5abae4
Binary files /dev/null and b/build/classes/com/touch/graduation/servlet/GetPublishedMessageSetvlet.class differ
diff --git a/build/classes/com/touch/graduation/servlet/LoginServlet.class b/build/classes/com/touch/graduation/servlet/LoginServlet.class
new file mode 100644
index 0000000..e3d71b1
Binary files /dev/null and b/build/classes/com/touch/graduation/servlet/LoginServlet.class differ
diff --git a/build/classes/com/touch/graduation/servlet/PushMessageServlet.class b/build/classes/com/touch/graduation/servlet/PushMessageServlet.class
new file mode 100644
index 0000000..69228d4
Binary files /dev/null and b/build/classes/com/touch/graduation/servlet/PushMessageServlet.class differ
diff --git a/build/classes/com/touch/graduation/servlet/RegisterServlet.class b/build/classes/com/touch/graduation/servlet/RegisterServlet.class
new file mode 100644
index 0000000..8c17f2f
Binary files /dev/null and b/build/classes/com/touch/graduation/servlet/RegisterServlet.class differ
diff --git a/build/classes/com/touch/graduation/servlet/RemoveBookFromBookToChangedBookServlet.class b/build/classes/com/touch/graduation/servlet/RemoveBookFromBookToChangedBookServlet.class
new file mode 100644
index 0000000..44a9a98
Binary files /dev/null and b/build/classes/com/touch/graduation/servlet/RemoveBookFromBookToChangedBookServlet.class differ
diff --git a/build/classes/com/touch/graduation/servlet/SetAccountIntroduceServlet.class b/build/classes/com/touch/graduation/servlet/SetAccountIntroduceServlet.class
new file mode 100644
index 0000000..3fe8173
Binary files /dev/null and b/build/classes/com/touch/graduation/servlet/SetAccountIntroduceServlet.class differ
diff --git a/build/classes/com/touch/graduation/util/Util.class b/build/classes/com/touch/graduation/util/Util.class
new file mode 100644
index 0000000..f89b569
Binary files /dev/null and b/build/classes/com/touch/graduation/util/Util.class differ
diff --git a/lib/commons-codec-1.8.jar b/lib/commons-codec-1.8.jar
new file mode 100644
index 0000000..32f84c9
Binary files /dev/null and b/lib/commons-codec-1.8.jar differ
diff --git a/lib/mysql-connector-java-5.1.26-bin.jar b/lib/mysql-connector-java-5.1.26-bin.jar
new file mode 100644
index 0000000..bf1e933
Binary files /dev/null and b/lib/mysql-connector-java-5.1.26-bin.jar differ
diff --git a/src/com/touch/graduation/common/Book.java b/src/com/touch/graduation/common/Book.java
new file mode 100644
index 0000000..d02a05e
--- /dev/null
+++ b/src/com/touch/graduation/common/Book.java
@@ -0,0 +1,184 @@
+package com.touch.graduation.common;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+public class Book implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * ͼ������ݿ�洢ID
+ */
+ private int bookId;
+
+ /**
+ * �洢�û��ϴ���ͼƬ����
+ */
+ private int photoListSize;
+
+ /**
+ * �洢�û��ϴ���ͼ����Ƭ
+ */
+ private List photoList;
+
+ /**
+ * ͼ������
+ */
+ private String bookName;
+
+ /**
+ * ��������
+ */
+ private String bookAuthor;
+
+ /**
+ * ͼ����
+ */
+ private String bookContent;
+
+ /**
+ * �����
+ */
+ private String location;
+
+ /**
+ * ��ϵ����
+ */
+ private int contactTypeNow;
+
+ /**
+ * ������ϵ;��
+ */
+ private String otherContactType;
+
+ /**
+ * ��ϵ��ʽ
+ */
+ private String contactNumber;
+
+ /**
+ * ����ʱ��
+ */
+ private String pushTime;
+
+ /**
+ * �������˻���
+ */
+ private String account;
+
+ /**
+ * �û�id
+ */
+ private int userId;
+
+ public int getBookId() {
+ return bookId;
+ }
+
+ public void setBookId(int bookId) {
+ this.bookId = bookId;
+ }
+
+ public int getPhotoListSize() {
+ return photoListSize;
+ }
+
+ public void setPhotoListSize(int photoListSize) {
+ this.photoListSize = photoListSize;
+ }
+
+ public List getPhotoList() {
+ return photoList;
+ }
+
+ public void setPhotoList(List photoList) {
+ this.photoList = photoList;
+ }
+
+ public String getBookName() {
+ return bookName;
+ }
+
+ public void setBookName(String bookName) {
+ this.bookName = bookName;
+ }
+
+ public String getBookAuthor() {
+ return bookAuthor;
+ }
+
+ public void setBookAuthor(String bookAuthor) {
+ this.bookAuthor = bookAuthor;
+ }
+
+ public String getBookContent() {
+ return bookContent;
+ }
+
+ public void setBookContent(String bookContent) {
+ this.bookContent = bookContent;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public int getContactTypeNow() {
+ return contactTypeNow;
+ }
+
+ public void setContactTypeNow(int contactTypeNow) {
+ this.contactTypeNow = contactTypeNow;
+ }
+
+ public String getOtherContactType() {
+ return otherContactType;
+ }
+
+ public void setOtherContactType(String otherContactType) {
+ this.otherContactType = otherContactType;
+ }
+
+ public String getContactNumber() {
+ return contactNumber;
+ }
+
+ public void setContactNumber(String contactNumber) {
+ this.contactNumber = contactNumber;
+ }
+
+ public String getPushTime() {
+ return pushTime;
+ }
+
+ public void setPushTime(String pushTime) {
+ this.pushTime = pushTime;
+ }
+
+ public static long getSerialversionuid() {
+ return serialVersionUID;
+ }
+
+ public String getAccount() {
+ return account;
+ }
+
+ public void setAccount(String account) {
+ this.account = account;
+ }
+
+ public int getUserId() {
+ return userId;
+ }
+
+ public void setUserId(int userId) {
+ this.userId = userId;
+ }
+
+}
diff --git a/src/com/touch/graduation/database/ConnectDatabase.java b/src/com/touch/graduation/database/ConnectDatabase.java
new file mode 100644
index 0000000..584384b
--- /dev/null
+++ b/src/com/touch/graduation/database/ConnectDatabase.java
@@ -0,0 +1,72 @@
+package com.touch.graduation.database;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import com.touch.graduation.util.Util;
+
+public class ConnectDatabase {
+
+ public static Connection getConnection() {
+
+ Connection conn = null;
+
+ // ������������
+ try {
+ Class.forName(Util.DRIVER);
+
+ // �������ݿ�
+ conn = DriverManager.getConnection(Util.URL, Util.DATA_USER,
+ Util.DATA_PASSWORD);
+
+ if (!conn.isClosed())
+ System.out.println("Succeeded connecting to the Database!");
+
+ /*
+ * // statement����ִ��SQL��� Statement statement =
+ * conn.createStatement();
+ *
+ * // Ҫִ�е�SQL��� String sql = "select * from book";
+ *
+ * // ����� ResultSet rs = statement.executeQuery(sql);
+ *
+ *
+ * String name = null;
+ *
+ * while (rs.next()) {
+ *
+ * // ѡ��sname�������� name = rs.getString("book_name");
+ *
+ * // ����ʹ��ISO-8859-1�ַ�����name����Ϊ�ֽ����в�������洢�µ��ֽ������С� //
+ * Ȼ��ʹ��GB2312�ַ�������ָ�����ֽ����� name = new
+ * String(name.getBytes("ISO-8859-1"), "GB2312");
+ *
+ * // ������ System.out.println(rs.getString("book_name") + "\t" +
+ * name); }
+ *
+ * rs.close();
+ */
+
+ } catch (ClassNotFoundException e) {
+ System.out
+ .println("ClassNotFoundException, fail connecting to the Database!");
+ e.printStackTrace();
+ } catch (SQLException e) {
+ System.out
+ .println("SQLException, fail connecting to the Database!");
+ e.printStackTrace();
+ }
+
+
+ return conn;
+
+ }
+
+ public static void main (String[] agrs) {
+ getConnection();
+ }
+
+}
diff --git a/src/com/touch/graduation/database/OperateDatabase.java b/src/com/touch/graduation/database/OperateDatabase.java
new file mode 100644
index 0000000..a8983c1
--- /dev/null
+++ b/src/com/touch/graduation/database/OperateDatabase.java
@@ -0,0 +1,507 @@
+package com.touch.graduation.database;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import com.touch.graduation.common.Book;
+import com.touch.graduation.util.Util;
+
+public class OperateDatabase {
+
+ @SuppressWarnings("resource")
+ public static boolean insertData(Book book) {
+
+ boolean result = false;
+
+ String sql = "insert into book "
+ + "(book_name, book_author, book_content, book_location, "
+ + "contact_type, contact_number, push_time, pic_number, other_contact_type)"
+ + "values(?,?,?,?,?,?,?,?,?)";
+
+ String sqlNoOtherType = "insert into book "
+ + "(book_name, book_author, book_content, book_location, "
+ + "contact_type, contact_number, push_time, pic_number) "
+ + "values(?,?,?,?,?,?,?,?)";
+
+ String sqlInsertPhoto = "insert into book_picture (book_id, book_pic) value(?,?)";
+
+ String sqlSelectBookId = "select book_id from book where book_name = '"
+ + book.getBookName() + "' AND contact_number = '"
+ + book.getContactNumber() + "' AND book_author = '"
+ + book.getBookAuthor() + "'";
+
+ String sqlSelectUserId = "select user_id from user where account = '"
+ + book.getAccount() + "'";
+
+ String sqlInsertIntoUserPushBook = "insert into user_push_book (user_id, book_id) value (?,?)";
+
+ Connection conn = ConnectDatabase.getConnection();
+
+ if (conn != null) {
+ PreparedStatement ps = null;
+ Statement statement = null;
+ try {
+ if (book.getOtherContactType() != null) {
+ ps = conn.prepareStatement(sql);
+ ps.setString(9, book.getOtherContactType());
+ } else {
+ ps = conn.prepareStatement(sqlNoOtherType);
+ }
+ ps.setString(1, book.getBookName());
+ ps.setString(2, book.getBookAuthor());
+ ps.setString(3, book.getBookContent());
+ ps.setString(4, book.getLocation());
+ ps.setInt(5, book.getContactTypeNow());
+ ps.setString(6, book.getContactNumber());
+ ps.setString(7, book.getPushTime());
+ ps.setInt(8, book.getPhotoListSize());
+ int count = ps.executeUpdate();
+ if (count != 0) {
+ // result = true;
+ // �����������ݳɹ�������ѯ����ĸ������ݵ�id��Ȼ�����ͼƬ
+ statement = conn.createStatement();
+ ResultSet rs = statement.executeQuery(sqlSelectBookId);
+ int bookId = 0;
+ if (rs.next()) {
+ bookId = rs.getInt("book_id");
+ }
+ System.out.println("bookId = " + bookId);
+ // ��ѯͼ��id�ɹ�������Ƭ������Ƭ�ı�
+ List picList = book.getPhotoList();
+ for (String everyPic : picList) {
+ ps = conn.prepareStatement(sqlInsertPhoto);
+ ps.setInt(1, bookId);
+ ps.setString(2, everyPic);
+ count = ps.executeUpdate();
+ if (count != 0) {
+ continue;
+ } else {
+ System.out
+ .println("I'm sorry! This is OperateDatabase.java,something has mistake");
+ }
+ }
+ if (count != 0) {
+ // result = true;
+ // �������ݲ���ɹ����������û�����ͼ��ı�
+ statement = conn.createStatement();
+ ResultSet rsUserId = statement
+ .executeQuery(sqlSelectUserId);
+ int userId = 0;
+ if (rsUserId.next()) {
+ userId = rsUserId.getInt("user_id");
+ }
+ System.out.println("userId = " + userId);
+ // ��ѯ�û�id�ɹ�����ͼ��id���û�ID����user_push_book����
+ ps = conn.prepareStatement(sqlInsertIntoUserPushBook);
+ ps.setInt(1, userId);
+ ps.setInt(2, bookId);
+ count = ps.executeUpdate();
+ if (count != 0) {
+ result = true;
+ }
+ }
+
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ ps.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return result;
+
+ }
+
+ public static String login(String account, String password) {
+ String result = Util.LOGIN_FAIL_TAG;
+ String sqlSelectUser = "select user_id from user "
+ + "where account = '" + account + "' and password = '"
+ + password + "'";
+ Connection conn = ConnectDatabase.getConnection();
+ Statement statement = null;
+ if (conn != null) {
+ try {
+ statement = conn.createStatement();
+ ResultSet rs = statement.executeQuery(sqlSelectUser);
+ if (rs.next()) {
+ result = Util.LOGIN_SUCCESS_TAG;
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ return result;
+ }
+
+ public static String register(String account, String password,
+ String telephone) {
+ String result = Util.REGISTER_FAIL_TAG;
+ String sqlInsertUser = "insert into user (account, password, telephone) values (?, ?, ?)";
+ Connection conn = ConnectDatabase.getConnection();
+
+ if (conn != null) {
+ PreparedStatement ps = null;
+ try {
+ ps = conn.prepareStatement(sqlInsertUser);
+ ps.setString(1, account);
+ ps.setString(2, password);
+ ps.setString(3, telephone);
+ int count = ps.executeUpdate();
+ if (count != 0) {
+ result = Util.REGISTER_SUCCESS_TAG;
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ return result;
+ }
+
+ public static List getBookMessageListByLocation(String location) {
+ List bookMessageList = new ArrayList();
+
+ String selectBookMessageByLocation = "select book_id, book_name, book_author, book_content, "
+ + "contact_type, other_contact_type, contact_number,"
+ + "push_time, pic_number "
+ + "from book "
+ + "where book_location = '" + location + "'" + "ORDER BY book_id DESC";
+
+ Statement statement = null;
+ Connection conn = ConnectDatabase.getConnection();
+ if (conn != null) {
+
+ try {
+ statement = conn.createStatement();
+ ResultSet rs = statement
+ .executeQuery(selectBookMessageByLocation);
+ while (rs.next()) {
+ Book book = new Book();
+ int bookId = rs.getInt("book_id");
+ String bookName = rs.getString("book_name");
+ String bookAuthor = rs.getString("book_author");
+ String bookContent = rs.getString("book_content");
+ int contactType = rs.getInt("contact_type");
+ String otherContactType = rs
+ .getString("other_contact_type");
+ String contactNumber = rs.getString("contact_number");
+
+ String pushTime = rs.getString("push_time");
+
+ int picNumber = rs.getInt("pic_number");
+ /*
+ * List photoList = new ArrayList();
+ *
+ * //���������Ҫ�ֿ���ѯ�����������Ǵ����û�������������� String
+ * selectBookPictureByBookId =
+ * "select book_pic from book_picture where book_id = '" +
+ * bookId + "'"; ResultSet rsBookPic =
+ * statement.executeQuery(selectBookPictureByBookId);
+ * while(rsBookPic.next()) { //���ڲ�ѯ����ͼƬ·��Ϊ������������·��
+ * //����δ��������ֱ��ת���ͻ����ٽ��д���������
+ * photoList.add(rsBookPic.getString("book_pic")); }
+ */
+ book.setBookId(bookId);
+ book.setBookName(bookName);
+ book.setBookAuthor(bookAuthor);
+ book.setBookContent(bookContent);
+ book.setContactTypeNow(contactType);
+ book.setOtherContactType(otherContactType);
+ book.setContactNumber(contactNumber);
+ book.setPushTime(pushTime);
+ book.setPhotoListSize(picNumber);
+ // book.setPhotoList(photoList);
+ bookMessageList.add(book);
+ }
+
+ for (Book book : bookMessageList) {
+ String selectBookPictureByBookId = "select book_pic from book_picture where book_id = '"
+ + book.getBookId() + "'";
+ ResultSet rsBookPic = statement
+ .executeQuery(selectBookPictureByBookId);
+ List photoList = new ArrayList();
+ while (rsBookPic.next()) {
+ photoList.add(rsBookPic.getString("book_pic"));
+ }
+ book.setPhotoList(photoList);
+
+ String selectUserIdByBookId = "select account from user_push_book, user where user.user_id = user_push_book.user_id and book_id = '"
+ + book.getBookId() + "'";
+ ResultSet rsUserId = statement
+ .executeQuery(selectUserIdByBookId);
+ String account = null;
+ if (rsUserId.next()) {
+ account = rsUserId.getString("account");
+ }
+ book.setAccount(account);
+ }
+
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ return bookMessageList;
+ }
+
+ public static String getAccountIntroduceByAccount(String account) {
+
+ String result = null;
+
+ String selectAccountIntroduceByAccount = "select introduce from user where account = '"
+ + account + "'";
+
+ Statement statement = null;
+ Connection conn = ConnectDatabase.getConnection();
+ if (conn != null) {
+ try {
+ statement = conn.createStatement();
+ ResultSet rs = statement
+ .executeQuery(selectAccountIntroduceByAccount);
+ if (rs.next()) {
+ result = rs.getString("introduce");
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ try {
+ conn.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ return result;
+
+ }
+
+ public static String updateAccountIntroduceByAccount(String account,
+ String introduce) {
+
+ String result = null;
+
+ String selectAccountIntroduceByAccount = "UPDATE user SET introduce = '"
+ + introduce + "' WHERE account = '" + account + "'";
+
+ Connection conn = ConnectDatabase.getConnection();
+ if (conn != null) {
+ PreparedStatement ps = null;
+ try {
+ ps = conn.prepareStatement(selectAccountIntroduceByAccount);
+ int count = ps.executeUpdate();
+ if (count != 0) {
+ result = "success";
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ if (null != ps) {
+ try {
+ ps.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return result;
+
+ }
+
+ public static ArrayList getPublicBookMessageListByLocation(
+ String account) {
+
+ ArrayList result = new ArrayList();
+
+ String selectPublishedBookMessageByAccount = "select book.book_id, book.book_name, book.book_author, book.push_time "
+ + "from user, user_push_book, book "
+ + "where user.user_id = user_push_book.user_id "
+ + "AND user_push_book.book_id = book.book_id "
+ + "AND user.account = '" + account + "'";
+
+ Statement statement = null;
+ Connection conn = ConnectDatabase.getConnection();
+
+ if (conn != null) {
+ try {
+ statement = conn.createStatement();
+ ResultSet rs = statement
+ .executeQuery(selectPublishedBookMessageByAccount);
+ while (rs.next()) {
+ Book book = new Book();
+ int bookId = rs.getInt("book_id");
+ String name = rs.getString("book_name");
+ String author = rs.getString("book_author");
+ String date = rs.getString("push_time");
+ book.setBookId(bookId);
+ book.setBookName(name);
+ book.setBookAuthor(author);
+ book.setPushTime(date);
+ result.add(book);
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ try {
+ conn.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ return result;
+
+ }
+
+ public static boolean removeBookFromBookToChangedBook(int bookId) {
+
+ boolean result = false;
+ //���ȣ�ͨ��bookid��ͼ����Ϣ��ѯ������������ChangedBook����Ȼ��ɾ�������Ϣ
+
+ Book book = new Book();
+ String selectBookMessageByBookIdSql = "SELECT book_name, book_author, push_time, user_id FROM book, user_push_book WHERE book.book_id = '" + bookId + "'" + "AND user_push_book.book_id = book.book_id";
+ String insertBookMessageToChangedBookSql = "insert into changed_book "
+ + "(changed_book_name, changed_book_author, changed_book_pushtime, changed_book_userid)"
+ + "values(?,?,?,?)";
+ String deleteBookMessageFromBookPictureSql = "DELETE FROM book_picture WHERE book_id = '" + bookId + "'";
+ String deleteBookMessageFromUserPushBookSql = "DELETE FROM user_push_book WHERE book_id = '" + bookId + "'";
+ String deleteBookMessageFromBookSql = "DELETE FROM book WHERE book_id = '" + bookId + "'";
+
+ Statement statement = null;
+ Connection conn = ConnectDatabase.getConnection();
+
+ if (conn != null) {
+ try {
+ statement = conn.createStatement();
+ ResultSet rs = statement
+ .executeQuery(selectBookMessageByBookIdSql);
+ if (rs.next()) {
+ String name = rs.getString("book_name");
+ String author = rs.getString("book_author");
+ String date = rs.getString("push_time");
+ int userId = rs.getInt("user_id");
+ book.setBookName(name);
+ book.setBookAuthor(author);
+ book.setPushTime(date);
+ book.setUserId(userId);
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ PreparedStatement ps = null;
+ try {
+ ps = conn.prepareStatement(insertBookMessageToChangedBookSql);
+
+ ps.setString(1, book.getBookName());
+ ps.setString(2, book.getBookAuthor());
+ ps.setString(3, book.getPushTime());
+ ps.setInt(4, book.getUserId());
+
+ int count = ps.executeUpdate();
+ if (count != 0) {
+ //��ʾ����ɹ�����ʼɾ��BookPicture���е�����
+ ps = conn.prepareStatement(deleteBookMessageFromBookPictureSql);
+ count = ps.executeUpdate();
+ if(count != 0) {
+ //��ʾɾ���ɹ�������ɾ��user_push_book���е�����
+ ps = conn.prepareStatement(deleteBookMessageFromUserPushBookSql);
+ count = ps.executeUpdate();
+ if(count != 0) {
+ //��ʾɾ���ɹ�������ɾ��book���е�����
+ ps = conn.prepareStatement(deleteBookMessageFromBookSql);
+ count = ps.executeUpdate();
+ if(count != 0) {
+ //��ʾɾ���ɹ���
+ result = true;
+ }
+ }
+ }
+
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ if (null != ps) {
+ try {
+ ps.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ try {
+ conn.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ return result;
+
+ }
+
+ public static ArrayList getGivedBookMessageListByLocation(
+ String account) {
+
+ ArrayList result = new ArrayList();
+
+ String selectGivededBookMessageByAccount = "select changed_book_name, changed_book_author, changed_book_pushtime "
+ + "from changed_book, user "
+ + "where user.account = '" + account + "'" + "AND changed_book.changed_book_userid = user.user_id";
+
+ Statement statement = null;
+ Connection conn = ConnectDatabase.getConnection();
+
+ if (conn != null) {
+ try {
+ statement = conn.createStatement();
+ ResultSet rs = statement
+ .executeQuery(selectGivededBookMessageByAccount);
+ while (rs.next()) {
+ Book book = new Book();
+ String name = rs.getString("changed_book_name");
+ String author = rs.getString("changed_book_author");
+ String date = rs.getString("changed_book_pushtime");
+ book.setBookName(name);
+ book.setBookAuthor(author);
+ book.setPushTime(date);
+ result.add(book);
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ try {
+ conn.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ return result;
+
+ }
+
+}
diff --git a/src/com/touch/graduation/servlet/GetAccountIntroduceServlet.java b/src/com/touch/graduation/servlet/GetAccountIntroduceServlet.java
new file mode 100644
index 0000000..ad31e34
--- /dev/null
+++ b/src/com/touch/graduation/servlet/GetAccountIntroduceServlet.java
@@ -0,0 +1,43 @@
+package com.touch.graduation.servlet;
+
+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;
+
+import com.touch.graduation.database.OperateDatabase;
+import com.touch.graduation.util.Util;
+
+public class GetAccountIntroduceServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ doPost(req, resp);
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ req.setCharacterEncoding("UTF-8");
+ resp.setCharacterEncoding("UTF-8");
+
+ System.out.println("I'm in GetAccountIntroduceServlet doPost()");
+
+ String account = req.getParameter(Util.ACCOUNT_INTERNET);
+ System.out.println("account = " + account);
+
+ String accountIntroduce = OperateDatabase.getAccountIntroduceByAccount(account);
+ System.out.println(accountIntroduce);
+
+ PrintWriter printWriter = resp.getWriter();
+
+ printWriter.print(accountIntroduce);
+ }
+
+}
diff --git a/src/com/touch/graduation/servlet/GetGivedBookMessageServlet.java b/src/com/touch/graduation/servlet/GetGivedBookMessageServlet.java
new file mode 100644
index 0000000..6a62428
--- /dev/null
+++ b/src/com/touch/graduation/servlet/GetGivedBookMessageServlet.java
@@ -0,0 +1,46 @@
+package com.touch.graduation.servlet;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.touch.graduation.common.Book;
+import com.touch.graduation.database.OperateDatabase;
+import com.touch.graduation.util.Util;
+
+public class GetGivedBookMessageServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ doPost(req, resp);
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ req.setCharacterEncoding("UTF-8");
+
+ System.out.println("I'm in GetGivedBookMessageServlet doPost()");
+
+ String account = req.getParameter(Util.ACCOUNT_INTERNET);
+ System.out.println("account = " + account);
+
+ ArrayList bookMessageList = OperateDatabase
+ .getGivedBookMessageListByLocation(account);
+
+ ObjectOutputStream oos = new ObjectOutputStream(resp.getOutputStream());
+ oos.writeObject(bookMessageList);
+
+ oos.flush();
+ oos.close();
+ }
+
+}
diff --git a/src/com/touch/graduation/servlet/GetMessageServlet.java b/src/com/touch/graduation/servlet/GetMessageServlet.java
new file mode 100644
index 0000000..6eae759
--- /dev/null
+++ b/src/com/touch/graduation/servlet/GetMessageServlet.java
@@ -0,0 +1,49 @@
+package com.touch.graduation.servlet;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.touch.graduation.common.Book;
+import com.touch.graduation.database.OperateDatabase;
+import com.touch.graduation.util.Util;
+
+public class GetMessageServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ doPost(req, resp);
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ req.setCharacterEncoding("UTF-8");
+
+ System.out.println("I'm in GetMessageServlet doPost()");
+
+ String location = req.getParameter(Util.SELECT_BO0K_LOCATION_KEY);
+ System.out.println("location = " + location);
+
+ List bookMessageList = OperateDatabase.getBookMessageListByLocation(location);
+
+ ObjectOutputStream oos = new ObjectOutputStream(resp.getOutputStream());
+ oos.writeObject(bookMessageList);
+
+ oos.flush();
+ oos.close();
+
+
+ }
+
+
+
+}
diff --git a/src/com/touch/graduation/servlet/GetPublishedMessageSetvlet.java b/src/com/touch/graduation/servlet/GetPublishedMessageSetvlet.java
new file mode 100644
index 0000000..69d58b6
--- /dev/null
+++ b/src/com/touch/graduation/servlet/GetPublishedMessageSetvlet.java
@@ -0,0 +1,47 @@
+package com.touch.graduation.servlet;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.touch.graduation.common.Book;
+import com.touch.graduation.database.OperateDatabase;
+import com.touch.graduation.util.Util;
+
+public class GetPublishedMessageSetvlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ doPost(req, resp);
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ req.setCharacterEncoding("UTF-8");
+
+ System.out.println("I'm in GetPublishedMessageSetvlet doPost()");
+
+ String account = req.getParameter(Util.ACCOUNT_INTERNET);
+ System.out.println("account = " + account);
+
+ ArrayList bookMessageList = OperateDatabase
+ .getPublicBookMessageListByLocation(account);
+
+ ObjectOutputStream oos = new ObjectOutputStream(resp.getOutputStream());
+ oos.writeObject(bookMessageList);
+
+ oos.flush();
+ oos.close();
+ }
+
+}
diff --git a/src/com/touch/graduation/servlet/LoginServlet.java b/src/com/touch/graduation/servlet/LoginServlet.java
new file mode 100644
index 0000000..569fe64
--- /dev/null
+++ b/src/com/touch/graduation/servlet/LoginServlet.java
@@ -0,0 +1,45 @@
+package com.touch.graduation.servlet;
+
+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;
+
+import com.touch.graduation.database.OperateDatabase;
+import com.touch.graduation.util.Util;
+
+public class LoginServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ doPost(req, resp);
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ req.setCharacterEncoding("UTF-8");
+
+ System.out.println("I'm in LoginServlet doPost()");
+
+ String account = req.getParameter(Util.ACCOUNT_INTERNET);
+ System.out.println("account = " + account);
+
+ String password = req.getParameter(Util.PASSWORD_INTERNET);
+ System.out.println("password = " + password);
+
+ String result = OperateDatabase.login(account, password);
+
+ PrintWriter printWriter = resp.getWriter();
+
+ printWriter.print(result);
+
+ }
+
+}
diff --git a/src/com/touch/graduation/servlet/PushMessageServlet.java b/src/com/touch/graduation/servlet/PushMessageServlet.java
new file mode 100644
index 0000000..79f0823
--- /dev/null
+++ b/src/com/touch/graduation/servlet/PushMessageServlet.java
@@ -0,0 +1,136 @@
+package com.touch.graduation.servlet;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URLDecoder;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.codec.binary.Base64;
+
+import com.touch.graduation.common.Book;
+import com.touch.graduation.database.OperateDatabase;
+import com.touch.graduation.util.Util;
+
+public class PushMessageServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * �洢�ϴ�ͼ����Ϣ
+ */
+ private Book pushBook = new Book();
+
+ @Override
+ protected void doGet(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+
+ request.setCharacterEncoding("UTF-8");
+
+ System.out.println("I'm in PushMessageServlet doPost()");
+
+ int photoListSize = Integer.parseInt(URLDecoder.decode(
+ request.getParameter(Util.PHOTO_LIST_STRING_TO_INTERNET_SIZE),
+ "UTF-8"));
+ pushBook.setPhotoListSize(photoListSize);
+ System.out.println("photoListSize:" + photoListSize);
+
+ List photoListString = new ArrayList();
+ for (int i = 1; i <= photoListSize; i++) {
+
+ String tempString = request.getParameter(Util.PHOTO_LIST_STRING_TO_INTERNET + i);
+
+ FileOutputStream fos = null;
+ String savePath = request.getSession().getServletContext().getRealPath("/")+ "images";
+ if (!new File(savePath).isDirectory()) {
+ new File(savePath).mkdirs(); // ѡ���ϴ���Ŀ¼�˴�Ϊ��ǰĿ¼��û����
+ }
+ //�ļ�����·��
+ String savePngPath = savePath + File.separator + new Date().getTime()+ i + ".png";
+ System.out.println("PushMessageServlet:savePngPath:" + savePngPath);
+
+ fos = new FileOutputStream(savePngPath.toString());
+ byte[] bytes = tempString.getBytes("UTF-8");
+ Base64 a = new Base64();
+ bytes = a.decode(bytes);
+ fos.write(bytes);
+ fos.close();
+
+ photoListString.add(savePngPath);
+ //photoListString.add(request.getParameter(Util.PHOTO_LIST_STRING_TO_INTERNET + i));
+ // .getParameter(Util.PHOTO_LIST_STRING_TO_INTERNET));
+ }
+ pushBook.setPhotoList(photoListString);
+
+
+ String bookName = URLDecoder.decode(
+ request.getParameter(Util.BOOK_NAME_INTERNET), "UTF-8");
+ pushBook.setBookName(bookName);
+
+ String bookAuthor = URLDecoder.decode(
+ request.getParameter(Util.BOOK_AUTHOR_INTERNET), "UTF-8");
+ pushBook.setBookAuthor(bookAuthor);
+
+ String bookContent = URLDecoder.decode(
+ request.getParameter(Util.BOOK_CONTENT_INTERNET), "UTF-8");
+ pushBook.setBookContent(bookContent);
+
+ String showLocation = URLDecoder.decode(
+ request.getParameter(Util.BOOK_LOCATION_INTERNET), "UTF-8");
+ pushBook.setLocation(showLocation);
+
+ int contactType = Integer
+ .parseInt(URLDecoder.decode(
+ request.getParameter(Util.OWERN_CONTACT_TYPE_INTERNET),
+ "UTF-8"));
+ pushBook.setContactTypeNow(contactType);
+
+ if (2 == contactType) {
+ String otherContactType = URLDecoder.decode(request
+ .getParameter(Util.OWERN_OTHER_CONTACT_TYPE_INTERNET),
+ "UTF-8");
+ pushBook.setOtherContactType(otherContactType);
+ }
+
+ String contactNumber = URLDecoder.decode(
+ request.getParameter(Util.OWERN_CONTACT_NUMBER_INTERNET),
+ "UTF-8");
+ pushBook.setContactNumber(contactNumber);
+
+ SimpleDateFormat sdf = new SimpleDateFormat(
+ "yyyy-MM-dd HH:mm:ss");
+ String pushTime = sdf.format(new Date());
+ pushBook.setPushTime(pushTime);
+
+ String account = URLDecoder.decode(request.getParameter(Util.ACCOUNT_INTERNET),"UTF-8");
+ pushBook.setAccount(account);
+
+ boolean b = OperateDatabase.insertData(pushBook);
+
+ PrintWriter out = response.getWriter();
+ if (b) {
+ out.print("success");
+ } else {
+ out.print("fail");
+ }
+
+ out.flush();
+ out.close();
+ }
+
+}
diff --git a/src/com/touch/graduation/servlet/RegisterServlet.java b/src/com/touch/graduation/servlet/RegisterServlet.java
new file mode 100644
index 0000000..af1f8c3
--- /dev/null
+++ b/src/com/touch/graduation/servlet/RegisterServlet.java
@@ -0,0 +1,51 @@
+package com.touch.graduation.servlet;
+
+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;
+
+import com.touch.graduation.database.OperateDatabase;
+import com.touch.graduation.util.Util;
+
+public class RegisterServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ doPost(req, resp);
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ req.setCharacterEncoding("UTF-8");
+ System.out.println("I'm in RegisterServlet doPost()");
+
+ String account = req.getParameter(Util.ACCOUNT_INTERNET);
+ System.out.println("account = " + account);
+
+ String password = req.getParameter(Util.PASSWORD_INTERNET);
+ System.out.println("password = " + password);
+
+ String telephone = req.getParameter(Util.TELEPHONE_INTERNET);
+ System.out.println("password = " + telephone);
+
+ String result = OperateDatabase.register(account, password, telephone);
+
+ PrintWriter printWriter = resp.getWriter();
+
+ printWriter.print(result);
+
+ printWriter.flush();
+ printWriter.close();
+ }
+
+
+
+}
diff --git a/src/com/touch/graduation/servlet/RemoveBookFromBookToChangedBookServlet.java b/src/com/touch/graduation/servlet/RemoveBookFromBookToChangedBookServlet.java
new file mode 100644
index 0000000..040a24d
--- /dev/null
+++ b/src/com/touch/graduation/servlet/RemoveBookFromBookToChangedBookServlet.java
@@ -0,0 +1,43 @@
+package com.touch.graduation.servlet;
+
+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;
+
+import com.touch.graduation.database.OperateDatabase;
+import com.touch.graduation.util.Util;
+
+public class RemoveBookFromBookToChangedBookServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ doPost(req, resp);
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ req.setCharacterEncoding("UTF-8");
+
+ System.out.println("I'm in RemoveBookFromBookToChangedBookServlet doPost()");
+
+ int bookId = Integer.parseInt(req.getParameter(Util.DELETE_BOOK_ID_INTERNET));
+ System.out.println("bookId = " + bookId);
+
+ boolean result = OperateDatabase.removeBookFromBookToChangedBook(bookId);
+
+ System.out.println("result!!!!!!==" + result);
+
+ PrintWriter printWriter = resp.getWriter();
+
+ printWriter.print(result);
+ }
+
+}
diff --git a/src/com/touch/graduation/servlet/SetAccountIntroduceServlet.java b/src/com/touch/graduation/servlet/SetAccountIntroduceServlet.java
new file mode 100644
index 0000000..185f939
--- /dev/null
+++ b/src/com/touch/graduation/servlet/SetAccountIntroduceServlet.java
@@ -0,0 +1,46 @@
+package com.touch.graduation.servlet;
+
+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;
+
+import com.touch.graduation.database.OperateDatabase;
+import com.touch.graduation.util.Util;
+
+public class SetAccountIntroduceServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ doPost(req, resp);
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ req.setCharacterEncoding("UTF-8");
+
+ System.out.println("I'm in SetAccountIntroduceServlet doPost()");
+
+ String introduce = req.getParameter(Util.ACCOUNT_INTRODUCE_INTERNET);
+ System.out.println("introduce = " + introduce);
+
+ String account = req.getParameter(Util.ACCOUNT_INTERNET);
+ System.out.println("account = " + account);
+
+ String result = OperateDatabase.updateAccountIntroduceByAccount(account,introduce);
+
+ PrintWriter printWriter = resp.getWriter();
+
+ printWriter.print(result);
+ }
+
+
+
+}
diff --git a/src/com/touch/graduation/util/Util.java b/src/com/touch/graduation/util/Util.java
new file mode 100644
index 0000000..deee95a
--- /dev/null
+++ b/src/com/touch/graduation/util/Util.java
@@ -0,0 +1,118 @@
+package com.touch.graduation.util;
+
+import java.awt.Image;
+
+public class Util {
+
+ public static final String DRIVER = "com.mysql.jdbc.Driver";
+
+ public static final String URL = "jdbc:mysql://127.0.0.1:3306/change_book_db";
+
+ /**
+ * ���ݿ������û���
+ */
+ public static final String DATA_USER = "root";
+
+ /**
+ * ���ݿ���������
+ */
+ public static final String DATA_PASSWORD = "";
+
+ /**
+ * ���洢��Ƭ�������洢��BasicNameValuePair���ڽ���
+ */
+ public static final String PHOTO_LIST_STRING_TO_INTERNET= "photo_list_string_to_internet";
+
+ /**
+ * ���洢��Ƭ�������Ĵ�С�洢�����ڴ�ȡ��Ҫ
+ */
+ public static final String PHOTO_LIST_STRING_TO_INTERNET_SIZE = "photo_list_string_to_internet_size";
+
+ /**
+ * �洢ͼ�������������紫��
+ */
+ public static final String BOOK_NAME_INTERNET = "book_name_internet";
+
+ /**
+ * �洢ͼ���������������紫��
+ */
+ public static final String BOOK_AUTHOR_INTERNET = "book_author_internet";
+
+ /**
+ * �洢ͼ�����������紫��
+ */
+ public static final String BOOK_CONTENT_INTERNET = "book_content_internet";
+
+ /**
+ * ͼ��ӵ���ߵ�����λ��
+ */
+ public static final String BOOK_LOCATION_INTERNET = "book_location_internet";
+
+ /**
+ * ��ϵ;��
+ */
+ public static final String OWERN_CONTACT_TYPE_INTERNET = "owern_contact_type_internet";
+
+ /**
+ * ������ϵ;��
+ */
+ public static final String OWERN_OTHER_CONTACT_TYPE_INTERNET = "owern_other_contact_type_internet";
+
+ /**
+ * ��ϵ��ʽ
+ */
+ public static final String OWERN_CONTACT_NUMBER_INTERNET = "owern_contact_number_internet";
+
+ /**
+ * �û�����
+ */
+ public static final String ACCOUNT_INTERNET = "account_internet";
+
+ /**
+ * �û�����
+ */
+ public static final String PASSWORD_INTERNET = "password_internet";
+
+ /**
+ * �û��绰
+ */
+ public static final String TELEPHONE_INTERNET = "telephone_internet";
+
+ /**
+ * �û����ڵأ����ڲ�ѯ����ͼ��
+ */
+ public static final String SELECT_BO0K_LOCATION_KEY = "select_book_location_key";
+
+ /**
+ * ���ص�¼�ɹ����
+ */
+ public final static String LOGIN_SUCCESS_TAG = "success";
+
+ /**
+ * ���ص�¼ʧ�ܱ��
+ */
+ public final static String LOGIN_FAIL_TAG = "fail";
+
+ /**
+ * ����ע��ɹ����
+ */
+ public final static String REGISTER_SUCCESS_TAG = "success";
+
+ /**
+ * ����ע��ʧ�ܱ��
+ */
+ public final static String REGISTER_FAIL_TAG = "fail";
+
+ /**
+ * �����������ϴ��û����
+ */
+ public static final String ACCOUNT_INTRODUCE_INTERNET = "account_introduce_internet";
+
+ /**
+ * ͼ��ID�����������������Ҫɾ����ͼ��id
+ */
+ public static final String DELETE_BOOK_ID_INTERNET = "delete_book_id_internet";
+
+
+
+}