Skip to content

Commit

Permalink
hzuapps#4 servlet
Browse files Browse the repository at this point in the history
  • Loading branch information
Zjwjerry committed Nov 12, 2016
1 parent d3a3870 commit f610e31
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}

/**
* The doGet method of the servlet. <br>
*
* 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. <br>
*
* 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. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}


}
52 changes: 52 additions & 0 deletions jweb/web/1414080902203/Upload.jsp
Original file line number Diff line number Diff line change
@@ -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+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'Upload.jsp' starting page</title>
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<style type="text/css">
h1{color:red;text-decoration:underline;font-weight:bold;font-size:25px;}
h2{font-size:20px;color:blue;}
</style>
</head>

<body>
<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<form action="Se1414080902203Servlet" method="post">
<div id="01" style=" position:absolute; width:100%; height:100%; background-color:yellow"
<center> 现在的时间是: <%=new Date()%> :60S后刷新<hr>
<%response.setHeader("refresh","60");%>
</center>
</div>
<div id="02" style=" position:absolute; width:100%; height:100%; background-color:#33CC99">
<table border="0" align="center" width=400>
<tr><td align="center"><h1>Hello Teacher</h1></td></tr>

<tr><td colspan="2" ><h2>选择文件:*</h2><input type="file" accept="video/mp4" multiple="multiple" >
请输入验证码(Upload):<input type="text" name="Pass"><br>
<input type="submit" value="提交"><br>
<input type="reset"></td>

</tr>
</table>
</div>
</form>

</body>
</html>
30 changes: 30 additions & 0 deletions jweb/web/1414080902203/Waiting.jsp
Original file line number Diff line number Diff line change
@@ -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+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'Upload.jsp' starting page</title>
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<style type="text/css">
h1{color:red;text-decoration:underline;font-weight:bold;font-size:25px;}
</style>
</head>

<body>
<h1><%=request.getAttribute("OutputMessage") %></h1>
</body>
</html>

0 comments on commit f610e31

Please sign in to comment.