-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #305 from mpq1228/master
#4 提交实验代码
- Loading branch information
Showing
3 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
jweb/src/edu/hzu/javaweb/labs/se1406070302213/Se1406070302213Servlet.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,91 @@ | ||
package edu.hzu.javaweb.labs.se1406070302213; | ||
|
||
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 Se1406070302213Servlet extends HttpServlet { | ||
|
||
/** | ||
* Constructor of the object. | ||
*/ | ||
public Se1406070302213Servlet() { | ||
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 { | ||
|
||
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.println(" Hello!Mr Zeng!"); | ||
out.println(" <br>"); | ||
out.println(" My student number is 1406070302213.Thanks!"); | ||
out.println(" </BODY>"); | ||
out.println("</HTML>"); | ||
out.flush(); | ||
out.close(); | ||
} | ||
|
||
/** | ||
* 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.println(" Hello!Mr Zeng!"); | ||
out.println(" <br>"); | ||
out.println(" My student number is 1406070302213.Thanks!"); | ||
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,34 @@ | ||
|
||
<%@ 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> | ||
<link rel="stylesheet" type="text/css" href="mpq.css"/> | ||
<title>登录</title> | ||
<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
</head> | ||
<body> | ||
<center> | ||
<h1><%=new java.util.Date()%></h1> | ||
</center> | ||
<div id="main_special"> | ||
<fieldset><legend>登录</legend> | ||
<form action="1406070302213" method="get"> | ||
<label for="label1">用 户 名:</label> | ||
<input type="text" name="name" id="username label1"/><font style="font-size:12px;color:#898983"> *用户名不得超过16位字符</font><br> | ||
<label for="label2">密 码:</label> | ||
<input type="password" name="pw" id="password label2"/><font style="font-size:12px;color:#898983"> *密码不能超过16位字符</font><br> | ||
<input type="submit" name="submit" class="submit" value="登录"/> | ||
<input type="reset" name="reset" class="submit" value="重置"/> | ||
</form> | ||
</fieldset> | ||
</div> | ||
</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,30 @@ | ||
@CHARSET "UTF-8"; | ||
|
||
#main_special{ | ||
margin:80px 0 0 50px; | ||
} | ||
#main_special form input{ | ||
|
||
height:22px; | ||
margin-bottom:20px; | ||
} | ||
#main_special fieldset{ | ||
width:450px; | ||
} | ||
#main_special label{ | ||
font-size:15px; | ||
|
||
} | ||
#main_special #label4{ | ||
width:50px; | ||
} | ||
#main_special form{ | ||
margin:20px; | ||
padding:0px; | ||
} | ||
#main_special .submit{ | ||
margin:10px 0 0 0px; | ||
} | ||
#main_special img{ | ||
margin:0 0 0 80px; | ||
} |