-
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 #2 from hzuapps/master
update
- Loading branch information
Showing
287 changed files
with
49,723 additions
and
1 deletion.
There are no files selected for viewing
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
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+2.36 KB
jweb/build/classes/edu/hzu/javaweb/labs/se12345678/Se12345678Servlet.class
Binary file not shown.
Binary file added
BIN
+137 Bytes
jweb/build/classes/edu/hzu/javaweb/labs/se12345678/package-info.class
Binary file not shown.
Binary file not shown.
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,38 @@ | ||
/** | ||
* | ||
*/ | ||
package edu.hzu.javaweb.bean; | ||
|
||
/** | ||
* @author zengsn | ||
* @since 8.0 | ||
*/ | ||
public class UserData { | ||
private String username; | ||
private String email; | ||
private int age; | ||
|
||
public void setUsername(String value) { | ||
username = value; | ||
} | ||
|
||
public void setEmail(String value) { | ||
email = value; | ||
} | ||
|
||
public void setAge(int value) { | ||
age = value; | ||
} | ||
|
||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
public String getEmail() { | ||
return email; | ||
} | ||
|
||
public int getAge() { | ||
return age; | ||
} | ||
} |
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,7 @@ | ||
/** | ||
* 这里为实验的Java代码。各人的代码放在各自学号的包下。 | ||
* | ||
* @author zengsn | ||
* @since 8.0 | ||
*/ | ||
package edu.hzu.javaweb.labs; |
57 changes: 57 additions & 0 deletions
57
jweb/src/edu/hzu/javaweb/labs/se12345678/Se12345678Servlet.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,57 @@ | ||
package edu.hzu.javaweb.labs.se12345678; | ||
|
||
import java.io.IOException; | ||
import javax.servlet.ServletConfig; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import javax.servlet.http.HttpSession; | ||
|
||
@WebServlet("/1st") | ||
public class Se12345678Servlet extends HttpServlet { | ||
private static final long serialVersionUID = 1L; | ||
|
||
public Se12345678Servlet() { | ||
super(); | ||
} | ||
|
||
public void init(ServletConfig config) throws ServletException { | ||
|
||
} | ||
|
||
public void destroy() { | ||
} | ||
|
||
protected void doGet(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
// 已登录 | ||
String login = "zhang3"; | ||
// Session | ||
HttpSession session = request.getSession(true); | ||
session.setAttribute("username", login); // 登录之后 | ||
String username = (String) session.getAttribute("username"); | ||
if (username == null) { | ||
|
||
} | ||
|
||
session.setMaxInactiveInterval(15); | ||
|
||
// 返回HTML | ||
StringBuilder html = new StringBuilder(); | ||
html.append("<!DOCTYPE html><html><head>"); | ||
html.append("<title>First App</title>"); | ||
html.append("</head><body>"); | ||
html.append("<a id=\"link\" href=\"www.hzu.edu.cn\">惠州学院</a>"); | ||
html.append("</body></html>"); | ||
response.setCharacterEncoding("utf-8"); | ||
response.getWriter().append(html); | ||
} | ||
|
||
protected void doPost(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
doGet(request, response); | ||
} | ||
|
||
} |
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,8 @@ | ||
|
||
/** | ||
* 把 12345678 即为学号。 | ||
* | ||
* @author zengsn | ||
* @since 8.0 | ||
*/ | ||
package edu.hzu.javaweb.labs.se12345678; |
112 changes: 112 additions & 0 deletions
112
jweb/src/edu/hzu/javaweb/labs/se1414080902134/Se1414080902134Servlet.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,112 @@ | ||
package edu.hzu.javaweb.labs.se1414080902134; | ||
|
||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
import java.util.List; | ||
|
||
import javax.servlet.ServletContext; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import java.util.Enumeration; | ||
import java.util.Iterator; | ||
|
||
//import edu.hzu.javaweb.bean.se1414080902134.UserData; | ||
import javafx.application.Application; | ||
|
||
/** | ||
* Servlet implementation class Se1414080902134Servlet | ||
*/ | ||
@WebServlet("/1414080902134") | ||
public class Se1414080902134Servlet extends HttpServlet { | ||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* @see HttpServlet#HttpServlet() | ||
*/ | ||
public Se1414080902134Servlet() { | ||
super(); | ||
// TODO Auto-generated constructor stub | ||
} | ||
|
||
/** | ||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) | ||
*/ | ||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
// TODO Auto-generated method stub | ||
ServletContext application=this.getServletContext(); | ||
application.setAttribute("message","only dear with post method ."); | ||
response.sendRedirect("/1414080902134/Home.jsp"); | ||
// PrintWriter out = response.getWriter(); | ||
// UserData ud = new UserData(); | ||
// Enumeration<String> iter_ = (request.getParameterNames()); | ||
// while (iter_.hasMoreElements()) { | ||
// String key = iter_.nextElement(); | ||
// ud.setAttribute(key,request.getParameter(key)); | ||
// } | ||
// if (ud.getQuickCode().equals("")) { | ||
// if (!ud.isComplete()) { | ||
// out.write("Information is not full ."); | ||
// } else { | ||
// if (ud.getUserName().isEmpty()) { | ||
// out.write("Welcome , " + ud.getEmail()); | ||
// } else { | ||
// out.write("Welcome , " + ud.getUserName()); | ||
// } | ||
// } | ||
// } else { | ||
// out.write("QuickCode = " + ud.getQuickCode()); | ||
// } | ||
// | ||
// out.flush(); | ||
//response.getWriter().append("Served at: ").append(request.getContextPath()); | ||
} | ||
|
||
/** | ||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) | ||
*/ | ||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
// TODO Auto-generated method stub | ||
ServletContext application=this.getServletContext(); | ||
boolean isLogin = false; | ||
PrintWriter out = response.getWriter(); | ||
UserData ud = new UserData(); | ||
Enumeration<String> iter_ = (request.getParameterNames()); | ||
while (iter_.hasMoreElements()) { | ||
String key = iter_.nextElement(); | ||
ud.setAttribute(key,request.getParameter(key)); | ||
} | ||
if (ud.getQuickCode().equals("")) { | ||
if (!ud.isComplete()) { | ||
out.write("Information is not full ."); | ||
} else { | ||
if (ud.getUserName().isEmpty()) { | ||
out.write("Welcome , " + ud.getEmail()); | ||
isLogin = true; | ||
} else { | ||
out.write("Welcome , " + ud.getUserName()); | ||
isLogin = true; | ||
} | ||
} | ||
} else { | ||
out.write("QuickCode = " + ud.getQuickCode()); | ||
//isLogin = true; | ||
} | ||
if (ud.isComplete()) { | ||
if (isLogin) { | ||
application.setAttribute("UserData",ud); | ||
response.sendRedirect("1414080902134/HomeUser.jsp"); | ||
} else { | ||
//TO DO | ||
//SEARCH SOMETHING FROM DATABASE BY THE QUICKCODE | ||
} | ||
} else { | ||
response.sendRedirect("1414080902134/Home.jsp"); | ||
} | ||
out.flush(); | ||
} | ||
|
||
} |
80 changes: 80 additions & 0 deletions
80
jweb/src/edu/hzu/javaweb/labs/se1414080902134/UserData.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,80 @@ | ||
package edu.hzu.javaweb.bean.se1414080902134; | ||
|
||
public class UserData { | ||
private String UserName; | ||
private String Email; | ||
private String Password; | ||
private String QuickCode; | ||
private boolean Remeber; | ||
public UserData(){ | ||
UserName = ""; | ||
Email = ""; | ||
Password = ""; | ||
QuickCode = ""; | ||
Remeber = false; | ||
} | ||
public String getUserName() { | ||
return UserName; | ||
} | ||
public void setUserName(String userName) { | ||
UserName = userName; | ||
} | ||
public String getEmail() { | ||
return Email; | ||
} | ||
public void setEmail(String email) { | ||
Email = email; | ||
} | ||
public String getPassword() { | ||
return Password; | ||
} | ||
public void setPassword(String password) { | ||
Password = password; | ||
} | ||
public String getQuickCode(){ | ||
return QuickCode; | ||
} | ||
public void setQuickCode(String qc){ | ||
QuickCode = qc; | ||
} | ||
public boolean getRemeber() { | ||
return Remeber; | ||
} | ||
public void setRemeber(boolean reamber) { | ||
Remeber = reamber; | ||
} | ||
public void setAttribute(String key,String value){ | ||
//System.out.println(key + " +++ " + value); | ||
if (key.toLowerCase().equals("username")) { | ||
setUserName(value); | ||
} else if (key.toLowerCase().equals("email")) { | ||
setEmail(value); | ||
} else if (key.toLowerCase().equals("password")) { | ||
setPassword(value); | ||
} else if (key.toLowerCase().equals("quickcode")) { | ||
setQuickCode(value); | ||
} else if (key.toLowerCase().equals("Remeber")) { | ||
if (value.toLowerCase().equals("on")) { | ||
setRemeber(true); | ||
} | ||
} | ||
} | ||
public boolean isComplete(){ | ||
//System.out.println(Password + "\t" + UserName + "\t" + Email); | ||
if (QuickCode.equals("")) { | ||
if (Password.equals("")) { | ||
System.out.println("Password false"); | ||
return false; | ||
} else { | ||
if (UserName.equals("") && Email.equals("")) { | ||
System.out.println("UserName false"); | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
} | ||
} else { | ||
return true; | ||
} | ||
} | ||
} |
Oops, something went wrong.