From f610e31d6cad146577ee6b42d0135fdd2e31960f Mon Sep 17 00:00:00 2001 From: ZjwJerry <565691343@qq.com> Date: Sat, 12 Nov 2016 10:27:36 +0800 Subject: [PATCH] #4 servlet --- .../Se1414080902203Servlet.java | 78 +++++++++++++++++++ jweb/web/1414080902203/Upload.jsp | 52 +++++++++++++ jweb/web/1414080902203/Waiting.jsp | 30 +++++++ 3 files changed, 160 insertions(+) create mode 100644 jweb/src/edu/hzu/javaweb/labs/se1414080902203/Se1414080902203Servlet.java create mode 100644 jweb/web/1414080902203/Upload.jsp create mode 100644 jweb/web/1414080902203/Waiting.jsp diff --git a/jweb/src/edu/hzu/javaweb/labs/se1414080902203/Se1414080902203Servlet.java b/jweb/src/edu/hzu/javaweb/labs/se1414080902203/Se1414080902203Servlet.java new file mode 100644 index 00000000..78d0614b --- /dev/null +++ b/jweb/src/edu/hzu/javaweb/labs/se1414080902203/Se1414080902203Servlet.java @@ -0,0 +1,78 @@ +package edu.hzu.javaweb.labs.se1414080902203; + +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 Se1414080902203Servlet extends HttpServlet { + + /** + * Constructor of the object. + */ + public Se1414080902203Servlet() { + 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 { + + + } + + /** + * 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 passName=request.getParameter("Pass"); + String info=""; + if("Upload".equals(passName)) + { + info="Uploading Files,please hold on!"; + } + else{info="PassWord wrong!";} + request.setAttribute("OutputMessage",info); + request.getRequestDispatcher("/Waiting.jsp").forward(request,response); + } + + /** + * Initialization of the servlet.
+ * + * @throws ServletException if an error occurs + */ + public void init() throws ServletException { + // Put your code here + } + + +} diff --git a/jweb/web/1414080902203/Upload.jsp b/jweb/web/1414080902203/Upload.jsp new file mode 100644 index 00000000..9fac48d7 --- /dev/null +++ b/jweb/web/1414080902203/Upload.jsp @@ -0,0 +1,52 @@ +<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + My JSP 'Upload.jsp' starting page + + + + + + + + + + + + + +
+
现在的时间是: <%=new Date()%> :60S后刷新
+ <%response.setHeader("refresh","60");%> + +
+
+ + + + + + +

Hello Teacher

选择文件:*

+ 请输入验证码(Upload):
+
+
+
+
+ + + \ No newline at end of file diff --git a/jweb/web/1414080902203/Waiting.jsp b/jweb/web/1414080902203/Waiting.jsp new file mode 100644 index 00000000..505f566b --- /dev/null +++ b/jweb/web/1414080902203/Waiting.jsp @@ -0,0 +1,30 @@ +<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + My JSP 'Upload.jsp' starting page + + + + + + + + + + + +

<%=request.getAttribute("OutputMessage") %>

+ + \ No newline at end of file