forked from hzuapps/java-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
218 additions
and
0 deletions.
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
jweb/src/edu/hzu/javaweb/labs/se1414080902138/Se1414080902138Servlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package edu.hzu.javaweb.labs.se1414080902138; | ||
|
||
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 Se1414080902138Servlet extends HttpServlet { | ||
|
||
/** | ||
* Constructor of the object. | ||
*/ | ||
public Se1414080902138Servlet() { | ||
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 { | ||
String name=request.getParameter("Username"); | ||
String pwd=request.getParameter("UserPwd"); | ||
PrintWriter out = response.getWriter(); | ||
if (("HCJ".equals(name))&&"123".equals(pwd)) { | ||
request.getRequestDispatcher("/add.jsp").forward(request,response); | ||
} else if (name.equals("")) { | ||
out.println("<h3 align=center>"); | ||
out.println("<br><br><br><br><br>"); | ||
out.println("The User name can not be empty."); | ||
out.println("</h3>"); | ||
} else if (pwd.equals("")) { | ||
out.println("<h3 align=center>"); | ||
out.println("<br><br><br><br><br>"); | ||
out.println("The Password can not be empty."); | ||
out.println("</h3>");} | ||
else { | ||
out.println("<h3 align=center>"); | ||
out.println("<br><br><br><br><br>"); | ||
out.println(" The username and password you entered are not available,Please try again "); | ||
out.println("</h3>"); | ||
} | ||
} | ||
|
||
/** | ||
* 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("<HTML>"); | ||
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>"); | ||
out.println(" <BODY >"); | ||
out.println("<h3 align=center>"); | ||
out.println("<br><br><br><br><br>"); | ||
out.println(" Hello,HCJ! "); | ||
out.println("<br><br>"); | ||
out.println("The message has been updated!"); | ||
out.println("</h3>"); | ||
out.println(" </BODY>"); | ||
out.println("</HTML>"); | ||
out.flush(); | ||
out.close(); | ||
} | ||
|
||
/** | ||
* Initialization of the servlet. <br> | ||
* | ||
* @throws ServletException if an error occurs | ||
*/ | ||
public void init() throws ServletException { | ||
// Put your code here | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> | ||
<html> | ||
<!-- 新 Bootstrap 核心 CSS 文件 --> | ||
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css"> | ||
<!-- 可选的Bootstrap主题文件(一般不用引入) --> | ||
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap-theme.min.css"> | ||
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 --> | ||
<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> | ||
<!-- 最新的 Bootstrap 核心 JavaScript 文件 --> | ||
<script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> | ||
<style type="text/css"> | ||
body{color:#FF7B0B;font-size:18px;} | ||
.title{text-align: center;font-size:50px;} | ||
.login{text-align: center;} | ||
#id,#name,#sex,#age,#weight,#hight{width:250px; margin:0 auto;} | ||
.btn{width: 125px;} | ||
</style> | ||
<head> | ||
<title>Add Page</title> | ||
</head> | ||
|
||
<body> | ||
<h1 class="title"><br/>New Information</h1> | ||
<div class="container" > | ||
<form action="123" method="post" class="login"><br> | ||
<div class="form-group"> | ||
<input type="text" class="form-control" id="id" name="Username" placeholder="please enter the new id"> | ||
</div> | ||
<div class="form-group"> | ||
<input type="text" class="form-control" id="name" name="UserPwd" placeholder="please enter the new name"> | ||
</div> | ||
<div class="form-group"> | ||
<input type="text" class="form-control" id="sex" name="UserPwd" placeholder="please enter the new sex"> | ||
</div> | ||
<div class="form-group"> | ||
<input type="text" class="form-control" id="age" name="UserPwd" placeholder="please enter the new age"> | ||
</div> | ||
<div class="form-group"> | ||
<input type="text" class="form-control" id="weight" name="UserPwd" placeholder="please enter the new weight"> | ||
</div> | ||
<div class="form-group"> | ||
<input type="text" class="form-control" id="hight" name="UserPwd" placeholder="please enter the new hight"> | ||
</div> | ||
<input type="submit" value="submit" class="btn btn-primary"> | ||
<input type="reset" value="reset" class="btn btn-primary"> | ||
</form> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<%@ 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> | ||
<!-- 新 Bootstrap 核心 CSS 文件 --> | ||
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css"> | ||
<!-- 可选的Bootstrap主题文件(一般不用引入) --> | ||
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap-theme.min.css"> | ||
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 --> | ||
<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> | ||
<!-- 最新的 Bootstrap 核心 JavaScript 文件 --> | ||
<script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> | ||
<style type="text/css"> | ||
body{color:#FF7B0B;font-size:18px;} | ||
.title{text-align: center;font-size:50px;} | ||
.login{text-align: center;} | ||
#InputName,#InputPassword{width:250px; margin:0 auto;} | ||
.checkbox{margin-left: -130px;} | ||
.btn{width: 253px;} | ||
</style> | ||
<head> | ||
<title>Login Page</title> | ||
</head> | ||
<body> | ||
<h1 class="title"><br/>Login</h1><br/> | ||
<div class="container" > | ||
<form role="form" class="login" action="123" method="get"> | ||
<div class="form-group"> | ||
<label for="InputName">Name</label> | ||
<input type="name" class="form-control" id="InputName" name="Username" placeholder="please enter your name"> | ||
</div> | ||
<div class="form-group"> | ||
<label for="InputPassword">Password</label> | ||
<input type="password" class="form-control" id="InputPassword" name="UserPwd" placeholder="please enter your password"> | ||
</div> | ||
<input type="submit" class="btn btn-primary" value="Submit"/> | ||
</form> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%> | ||
<% | ||
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 'info.jsp' starting page</title> | ||
|
||
<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"> | ||
--> | ||
|
||
</head> | ||
|
||
<body> | ||
<%=request.getAttribute("outputMessage")%> | ||
</body> | ||
</html> |