From 292d10a0ad0fafa1f0a3ed4746360b3bd862d8c4 Mon Sep 17 00:00:00 2001 From: hy346143551 <346143551@qq.com> Date: Thu, 10 Nov 2016 20:46:37 +0800 Subject: [PATCH 1/2] =?UTF-8?q?#4=20#91=20=E6=8F=90=E4=BA=A4=E5=AE=9E?= =?UTF-8?q?=E9=AA=8C=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../labs/se1414080902101/se1414080902101.java | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 jweb/src/edu/hzu/javaweb/labs/se1414080902101/se1414080902101.java diff --git a/jweb/src/edu/hzu/javaweb/labs/se1414080902101/se1414080902101.java b/jweb/src/edu/hzu/javaweb/labs/se1414080902101/se1414080902101.java new file mode 100644 index 00000000..ed15d567 --- /dev/null +++ b/jweb/src/edu/hzu/javaweb/labs/se1414080902101/se1414080902101.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 43a2df4c1eef47907abf15c29f87185b11edcb84 Mon Sep 17 00:00:00 2001 From: hy346143551 <346143551@qq.com> Date: Tue, 10 May 2016 10:50:07 +0800 Subject: [PATCH 2/2] =?UTF-8?q?#4=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Se1414080902101Servlet.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename jweb/src/edu/hzu/javaweb/labs/{se1414080902101/se1414080902101.java => Se1414080902101/Se1414080902101Servlet.java} (100%) diff --git a/jweb/src/edu/hzu/javaweb/labs/se1414080902101/se1414080902101.java b/jweb/src/edu/hzu/javaweb/labs/Se1414080902101/Se1414080902101Servlet.java similarity index 100% rename from jweb/src/edu/hzu/javaweb/labs/se1414080902101/se1414080902101.java rename to jweb/src/edu/hzu/javaweb/labs/Se1414080902101/Se1414080902101Servlet.java