Skip to content

Commit

Permalink
Merge pull request #510 from nihaomahenhaoba/master
Browse files Browse the repository at this point in the history
#4 #5提交试验代码 #397
  • Loading branch information
zengsn authored Nov 20, 2016
2 parents a4af4e4 + 974a5b5 commit 134e6ed
Show file tree
Hide file tree
Showing 5 changed files with 210 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package edu.hzu.javaweb.labs.se1414080902216;

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 Se1414080902216Servlet extends HttpServlet {

/**
* 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 {

response.setContentType("text/html;charset=utf-8");
PrintWriter out = response.getWriter();
out.println("您请求的是添加聚会记录");
}

/**
* 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 {

response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.print(" This is ");
out.print(this.getClass());
out.println(", using the POST method");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}

}
48 changes: 48 additions & 0 deletions jweb/src/edu/hzu/javaweb/labs/se1414080902216/firstFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package edu.hzu.javaweb.labs.se1414080902216;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


@WebFilter(filterName="firstFilter",urlPatterns="/1414080902216")
public class firstFilter implements Filter {

@Override
public void destroy() {
// TODO Auto-generated method stub

}

@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// TODO Auto-generated method stub
HttpServletRequest requ=(HttpServletRequest)request;
HttpServletResponse resp=(HttpServletResponse)response;
Cookie cookie = null;
Cookie[] cookies = null;
cookies = ((HttpServletRequest) request).getCookies();

if(cookies == null){
resp.sendRedirect("login.jsp");
}
}

@Override
public void init(FilterConfig filterConfig) throws ServletException {
System.out.println("¹ýÂË");

}

}

45 changes: 45 additions & 0 deletions jweb/web/1414080902216/index.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<%@ 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>
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">
<meta charset="utf-8">
<title>聚会添加系统</title>
<style>
.all{
width:300px;
height:400px;
border-style: solid;
border-color: black;
background-color: #C0B7BF;
position: absolute;
left:50%;
top:50%;
margin-left:-150px;
margin-top:-200px;
}
a{
text-decoration: none;
}
.text{
color:black;
font-weight: 700;
}
</style>
</head>
<body>
<div class="all">
<h2 align="center">聚会添加系统</h2>
<img src="juhui.jpg" alt="" width="100%"><br/><br/>
<div class="row">
<div class="col-xs-6 text"><button class="btn-info"><a href="1414080902216">添加聚会记录</a></button></div>
<div class="col-xs-6 text"><button class="btn-info"><a href="">查看聚会记录</a></button></div>
</div>
</div>
</body>
</html>
Binary file added jweb/web/1414080902216/juhui.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions jweb/web/1414080902216/login.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>java-web实验</title>

<!-- Bootstrap -->
<link href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<form role="form" id="target">
<div class="form-group">
<label for="exampleInputEmail1">用户名</label>
<input type="text" class="form-control" id="exampleInputEmail1" placeholder="Enter email">
</div>
<div class="form-group">
<label for="exampleInputPassword1">密码 </label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
</div>
<div class="checkbox">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script>
$( "#target" ).submit(function( event ) {
$.ajax({
url: "success.json"
}).done(function(data) {
if ( console && console.log ) {
console.dir(data);
alert(data.msg);
}
});
});
</script>
</body>
</html>

0 comments on commit 134e6ed

Please sign in to comment.