Skip to content

Commit a2fe0e8

Browse files
committed
网站注册,通过邮箱激活实例
1 parent 37f4b7e commit a2fe0e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+920
-0
lines changed

myMailWeb/.classpath

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5+
<classpathentry kind="con" path="melibrary.com.genuitec.eclipse.j2eedt.core.MYECLIPSE_JAVAEE_6_CONTAINER"/>
6+
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
7+
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
8+
<classpathentry kind="output" path="WebRoot/WEB-INF/classes"/>
9+
</classpath>

myMailWeb/.mymetadata

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project-module
3+
type="WEB"
4+
name="myMailWeb"
5+
id="myeclipse.1471831995257"
6+
context-root="/myMailWeb"
7+
j2ee-spec="6.0"
8+
archive="myMailWeb.war">
9+
<attributes>
10+
<attribute name="webrootdir" value="WebRoot" />
11+
</attributes>
12+
</project-module>
13+

myMailWeb/.project

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>myMailWeb</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.wst.common.project.facet.core.builder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>com.genuitec.eclipse.j2eedt.core.WebClasspathBuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>org.eclipse.jdt.core.javabuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
<buildCommand>
29+
<name>com.genuitec.eclipse.j2eedt.core.J2EEProjectValidator</name>
30+
<arguments>
31+
</arguments>
32+
</buildCommand>
33+
<buildCommand>
34+
<name>com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator</name>
35+
<arguments>
36+
</arguments>
37+
</buildCommand>
38+
<buildCommand>
39+
<name>org.eclipse.wst.validation.validationbuilder</name>
40+
<arguments>
41+
</arguments>
42+
</buildCommand>
43+
<buildCommand>
44+
<name>com.genuitec.eclipse.ast.deploy.core.DeploymentBuilder</name>
45+
<arguments>
46+
</arguments>
47+
</buildCommand>
48+
</buildSpec>
49+
<natures>
50+
<nature>com.genuitec.eclipse.ast.deploy.core.deploymentnature</nature>
51+
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
52+
<nature>com.genuitec.eclipse.j2eedt.core.webnature</nature>
53+
<nature>org.eclipse.jdt.core.javanature</nature>
54+
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
55+
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
56+
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
57+
</natures>
58+
</projectDescription>

myMailWeb/.settings/.jsdtscope

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="WebRoot"/>
4+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
5+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
6+
<attributes>
7+
<attribute name="hide" value="true"/>
8+
</attributes>
9+
</classpathentry>
10+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
11+
<classpathentry kind="output" path=""/>
12+
</classpath>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#Mon Aug 22 10:13:16 CST 2016
2+
eclipse.preferences.version=1
3+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
5+
org.eclipse.jdt.core.compiler.compliance=1.6
6+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8+
org.eclipse.jdt.core.compiler.source=1.6
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project-modules id="moduleCoreId" project-version="1.5.0">
3+
<wb-module deploy-name="myMailWeb">
4+
<wb-resource deploy-path="/" source-path="/WebRoot"/>
5+
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
6+
<property name="context-root" value="/myMailWeb"/>
7+
<property name="java-output-path" value="/myMailWeb/WebRoot/WEB-INF/classes"/>
8+
</wb-module>
9+
</project-modules>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<faceted-project>
3+
<fixed facet="wst.jsdt.web"/>
4+
<installed facet="java" version="1.6"/>
5+
<installed facet="jst.web" version="3.0"/>
6+
<installed facet="wst.jsdt.web" version="1.0"/>
7+
</faceted-project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Window

myMailWeb/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
网站用户注册:
2+
主要实现如下两个功能:
3+
1、用户在网站上注册完成后给用户发一封邮件。
4+
2、用户通过邮件激活后才可以登录。
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
Class-Path:
3+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<c3p0-config>
2+
<!-- 默认配置,如果没有指定则使用这个配置 -->
3+
<default-config>
4+
<property name="driverClass">com.mysql.jdbc.Driver</property>
5+
<property name="jdbcUrl">
6+
<![CDATA[jdbc:mysql://127.0.0.1:3306/hncu?useUnicode=true&characterEncoding=utf-8]]>
7+
</property>
8+
<property name="user">root</property>
9+
<property name="password">1234</property>
10+
<!-- 初始化池大小 -->
11+
<property name="initialPoolSize">2</property>
12+
<!-- 最大空闲时间 -->
13+
<property name="maxIdleTime">30</property>
14+
<!-- 最多有多少个连接 -->
15+
<property name="maxPoolSize">10</property>
16+
<!-- 最少几个连接 -->
17+
<property name="minPoolSize">2</property>
18+
<!-- 每次最多可以执行多少个批处理语句 -->
19+
<property name="maxStatements">50</property>
20+
</default-config>
21+
</c3p0-config>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
603 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

myMailWeb/WebRoot/WEB-INF/web.xml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<web-app version="3.0"
3+
xmlns="http://java.sun.com/xml/ns/javaee"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
6+
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
7+
<display-name></display-name>
8+
9+
<filter>
10+
<filter-name>charset</filter-name>
11+
<filter-class>cn.hncu.filter.CharsetFilter</filter-class>
12+
<init-param>
13+
<param-name>charset</param-name>
14+
<param-value>utf-8</param-value>
15+
</init-param>
16+
</filter>
17+
<filter-mapping>
18+
<filter-name>charset</filter-name>
19+
<url-pattern>/*</url-pattern>
20+
</filter-mapping>
21+
<servlet>
22+
<servlet-name>RegServlet</servlet-name>
23+
<servlet-class>cn.hncu.reg.servlet.RegServlet</servlet-class>
24+
</servlet>
25+
<servlet>
26+
<servlet-name>ActiveServlet</servlet-name>
27+
<servlet-class>cn.hncu.reg.servlet.ActiveServlet</servlet-class>
28+
</servlet>
29+
<servlet>
30+
<servlet-name>LoginServlet</servlet-name>
31+
<servlet-class>cn.hncu.login.servlet.LoginServlet</servlet-class>
32+
</servlet>
33+
34+
35+
36+
<servlet-mapping>
37+
<servlet-name>RegServlet</servlet-name>
38+
<url-pattern>/RegServlet</url-pattern>
39+
</servlet-mapping>
40+
<servlet-mapping>
41+
<servlet-name>ActiveServlet</servlet-name>
42+
<url-pattern>/ActiveServlet</url-pattern>
43+
</servlet-mapping>
44+
<servlet-mapping>
45+
<servlet-name>LoginServlet</servlet-name>
46+
<url-pattern>/LoginServlet</url-pattern>
47+
</servlet-mapping>
48+
49+
50+
<welcome-file-list>
51+
<welcome-file>index.jsp</welcome-file>
52+
</welcome-file-list>
53+
</web-app>

myMailWeb/WebRoot/index.jsp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
2+
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
3+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4+
<html>
5+
<head>
6+
<title>带邮箱激活的注册模块</title>
7+
8+
<script type="text/javascript">
9+
function reg(){
10+
//省略: 表单数据格式校验--还有ajax实现的验证码
11+
document.forms[0].action="<c:url value='RegServlet'/>";
12+
document.forms[0].submit();
13+
}
14+
function login(){
15+
document.forms[0].action="<c:url value='LoginServlet'/>";
16+
document.forms[0].submit();
17+
}
18+
</script>
19+
20+
</head>
21+
22+
<body>
23+
<c:if test="${!empty sessionScope.error}">
24+
登录失败!
25+
<c:remove var="error" scope="session"/>
26+
</c:if>
27+
28+
<c:if test="${empty sessionScope.user}" var="boo">
29+
<form action="" method="post">
30+
姓名:<input type="text" name="name" /> <br/>
31+
密码:<input type="password" name="pwd" /> <br/>
32+
邮箱:<input type="text" name="email" />-登录不用填写邮箱 <br/>
33+
<input type="button" value="注册" onclick="reg();"/> &nbsp;
34+
<input type="button" value="登录" onclick="login();"/> &nbsp;
35+
<input type="reset" value="重置"/>
36+
</form>
37+
</c:if>
38+
<c:if test="${!boo}">
39+
登录成功<br/>
40+
欢迎你,亲爱的${user.name}
41+
</c:if>
42+
</body>
43+
</html>

myMailWeb/WebRoot/jsps/result.jsp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
2+
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
3+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4+
<html>
5+
<head>
6+
<title>带邮箱激活的注册模块</title>
7+
8+
<script type="text/javascript">
9+
var tm;
10+
var i=5;
11+
function time(){
12+
i--;
13+
div1.innerHTML = i+"秒钟以后,自动去登录!";
14+
if(i<1){
15+
window.clearInterval(tm);//将定时器清除
16+
window.location.href="<c:url value='index.jsp'/>";
17+
}
18+
}
19+
20+
onload=function(){
21+
tm = window.setInterval(time, 1000);
22+
};
23+
</script>
24+
25+
</head>
26+
27+
<body>
28+
<c:if test="${count==-1}">
29+
服务器异常,请重新激活!<br/>
30+
<a href="<c:url value='/index.jsp'/>">登录</a>
31+
<br/>
32+
<div id="div1">
33+
</div>
34+
</c:if>
35+
<c:if test="${count==0}">
36+
激活地址错误,请使用正确的激活地址!<br/>
37+
<a href="<c:url value='/index.jsp'/>">登录</a>
38+
<br/>
39+
<div id="div1">
40+
</div>
41+
</c:if>
42+
<c:if test="${count==1}">
43+
你已经激活过,请勿重复激活!<br/>
44+
<a href="<c:url value='/index.jsp'/>">登录</a>
45+
<br/>
46+
<div id="div1">
47+
</div>
48+
</c:if>
49+
<c:if test="${count==2}">
50+
激活成功,欢迎去登录!<br/>
51+
<a href="<c:url value='/index.jsp'/>">登录</a>
52+
<br/>
53+
<div id="div1">
54+
</div>
55+
</c:if>
56+
</body>
57+
</html>

myMailWeb/WebRoot/sql/user.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
create table users(
2+
id varchar(32) primary key,
3+
name varchar(30),
4+
pwd varchar(32),
5+
email varchar(80),
6+
active char(1),
7+
acode varchar(32)
8+
);

myMailWeb/src/c3p0-config.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<c3p0-config>
2+
<!-- 默认配置,如果没有指定则使用这个配置 -->
3+
<default-config>
4+
<property name="driverClass">com.mysql.jdbc.Driver</property>
5+
<property name="jdbcUrl">
6+
<![CDATA[jdbc:mysql://127.0.0.1:3306/hncu?useUnicode=true&characterEncoding=utf-8]]>
7+
</property>
8+
<property name="user">root</property>
9+
<property name="password">1234</property>
10+
<!-- 初始化池大小 -->
11+
<property name="initialPoolSize">2</property>
12+
<!-- 最大空闲时间 -->
13+
<property name="maxIdleTime">30</property>
14+
<!-- 最多有多少个连接 -->
15+
<property name="maxPoolSize">10</property>
16+
<!-- 最少几个连接 -->
17+
<property name="minPoolSize">2</property>
18+
<!-- 每次最多可以执行多少个批处理语句 -->
19+
<property name="maxStatements">50</property>
20+
</default-config>
21+
</c3p0-config>

0 commit comments

Comments
 (0)