From 456cc03435f9a15bdbfc614682ccf89eefb71d98 Mon Sep 17 00:00:00 2001 From: Danivy <755793225@qq.com> Date: Thu, 20 Oct 2016 22:24:04 +0800 Subject: [PATCH] =?UTF-8?q?#4=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 --- .../Se1414080902205Servlet.java | 109 ++++++++++++++++++ jweb/web/1414080902205/META-INF/MANIFEST.MF | 3 + .../Se1414080902205Servlet.class | Bin 0 -> 2514 bytes jweb/web/1414080902205/WEB-INF/web.xml | 17 +++ jweb/web/1414080902205/index.jsp | 50 ++++++++ 5 files changed, 179 insertions(+) create mode 100644 jweb/src/edu/hzu/javaweb/labs/se1414080902205/Se1414080902205Servlet.java create mode 100644 jweb/web/1414080902205/META-INF/MANIFEST.MF create mode 100644 jweb/web/1414080902205/WEB-INF/classes/edu/hzu/javaweb/labs/se1414080902205/Se1414080902205Servlet.class create mode 100644 jweb/web/1414080902205/WEB-INF/web.xml create mode 100644 jweb/web/1414080902205/index.jsp diff --git a/jweb/src/edu/hzu/javaweb/labs/se1414080902205/Se1414080902205Servlet.java b/jweb/src/edu/hzu/javaweb/labs/se1414080902205/Se1414080902205Servlet.java new file mode 100644 index 00000000..c4e817f3 --- /dev/null +++ b/jweb/src/edu/hzu/javaweb/labs/se1414080902205/Se1414080902205Servlet.java @@ -0,0 +1,109 @@ +package edu.hzu.javaweb.labs.se1414080902205; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +@WebServlet("/1414080902205") +public class Se1414080902205Servlet extends HttpServlet { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public Se1414080902205Servlet() { + super(); + } + + + public void destroy() { + super.destroy(); // Just puts "destroy" string in log + // Put your code here + } + + + 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(); + doPost(request,response); + } + + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + response.setContentType("text/html"); + request.setCharacterEncoding("gb2312"); + response.setCharacterEncoding("gb2312"); + PrintWriter out = response.getWriter(); + String Account = new String(request.getParameter("account")); + String Amount = new String(request.getParameter("amount")); +// out.print(Account); +// out.print(Amount); + if (Account.equals("")) { + out.println("账号不能为空"); + } else if (Amount.equals("")) { + out.println("转账金额不能为空"); + } else { + boolean flat = true; + char[] str=Account.toCharArray(); + for (int i = 0;i < Account.length();i++) { + int x = str[i] - '0'; + if (!(x >= 0 && x <= 9)) { + out.println("请输入正确的账号"); + flat = false; + break; + } + } + if (flat) { + char[] sstr =Amount.toCharArray(); + for (int i = 0;i < Amount.length();i++) { + int x = sstr[i] - '0'; + if (!(x >= 0 && x <= 9)) { + out.println("请输入正确的转账金额"); + flat = false; + break; + } + } + } + if (flat) out.println("转账成功"); + } +// String Account = "1414080902205"; +// String Amount = "1414080902205"; +// out.println(Account); +// out.println(Amount); +// out.println(""); +//// out.println(""); +//// out.println(" A Servlet"); +//// out.println(" "); +//// out.print(" This is "); +//// out.print(this.getClass()); +//// out.println(", using the POST method"); +//// out.println(" "); +//// out.println(""); +//// out.flush(); +//// out.close(); + } + + public void init() throws ServletException { + // Put your code here + } + +} diff --git a/jweb/web/1414080902205/META-INF/MANIFEST.MF b/jweb/web/1414080902205/META-INF/MANIFEST.MF new file mode 100644 index 00000000..254272e1 --- /dev/null +++ b/jweb/web/1414080902205/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/jweb/web/1414080902205/WEB-INF/classes/edu/hzu/javaweb/labs/se1414080902205/Se1414080902205Servlet.class b/jweb/web/1414080902205/WEB-INF/classes/edu/hzu/javaweb/labs/se1414080902205/Se1414080902205Servlet.class new file mode 100644 index 0000000000000000000000000000000000000000..0e982cdfc9561fce2e668a24cfea5a34f3a8a1b7 GIT binary patch literal 2514 zcmbtUTTB#J82-+(yED5Cf~#9yZL7VgAmA;bQ{6^7W7^iCmYo7(uRu|gZDkzYa=P_Y z*6@*%{1XEH&8B5KTLlVA%en=;O?J` zkijq-q`$%D;e;{hFjN@@%N~nwKCDwp3Z4{LBxyuVJKAz!>LLi*YFL3K3~ADCw=-m{ zq;re}*38Q(M_oWo8##Ic^ZT23M8ztBfMX0hEQoNT9hX_G1fOG?Y!5X!K(lSuxeLBU4Wyql02 zELF%_(h~_gYdMnR77bgmO+X`LJKr5JT-4QbIhcEA23kW9^=Op+P_CkhzUu=LS4Fb` zh4t92VGmk(!F1~>w!y5x9fB_O6`Hn&gM8tSB`4v!HaYyWmvsVpF0*>R2*Y< z&tW!$g^E`g-W;#H=ia^Z*2lE9v+RQKoQb1Hjk)~DiSlRynLdA`8)Y&-p3(^;juMc= zLBP|)BnXo~##{_jBjd`8IvqW6V!uA<&LjoY@XF!FF7LFn>4dS%l=Ex(+~akfPxiZDo4yUwBaWlz^@!Aw}|u` zI`BK?N)&ndmu6x`Um+~Wmy0K literal 0 HcmV?d00001 diff --git a/jweb/web/1414080902205/WEB-INF/web.xml b/jweb/web/1414080902205/WEB-INF/web.xml new file mode 100644 index 00000000..b5d14c65 --- /dev/null +++ b/jweb/web/1414080902205/WEB-INF/web.xml @@ -0,0 +1,17 @@ + + + + This is the description of my J2EE component + This is the display name of my J2EE component + Se1414080902205Servlet + edu.hzu.javaweb.labs.se1414080902205.Se1414080902205Servlet + + + Se1414080902205Servlet + /servlet/Se1414080902205Servlet + + + \ No newline at end of file diff --git a/jweb/web/1414080902205/index.jsp b/jweb/web/1414080902205/index.jsp new file mode 100644 index 00000000..74e4b41f --- /dev/null +++ b/jweb/web/1414080902205/index.jsp @@ -0,0 +1,50 @@ + + + + + + + +ATM Transfer + + +
+

ATM Transfer

+
Now time is: + <%=new java.util.Date()%> +
+
+
+ + +
+
+ + +
+
+ +
+
+
+ + + + + + + \ No newline at end of file