⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 account.jsp

📁 Struts+Spring+Hibernate开发的BBS,功能很强大很完善
💻 JSP
字号:
<%@ page contentType="text/html;charset=ISO8859_1" %>
<%
/**
 *	$RCSfile: account.jsp,v $
 *	$Revision: 1.3 $
 *	$Date: 2002/09/30 14:56:16 $
 */
%>

<%@ page import="com.jivesoftware.forum.*,
                 com.jivesoftware.forum.util.*"
	errorPage="error.jsp"
%>

<%@ include file="global.jsp" %>

<%	// Get parameters
    boolean create = ParamUtils.getBooleanParameter(request,"create");
	String username = ParamUtils.getParameter(request,"username");
	String password = ParamUtils.getParameter(request,"password");
	String confirmPassword = ParamUtils.getParameter(request,"confirmPassword");
	String email = ParamUtils.getParameter(request,"email");
	String name = ParamUtils.getParameter(request,"name");
    String location = ParamUtils.getParameter(request,"location");
    String occupation = ParamUtils.getParameter(request,"occupation");
    String homepage = ParamUtils.getParameter(request,"homepage");
	boolean autoLogin = ParamUtils.getBooleanParameter(request,"autoLogin");
	String referrer = ParamUtils.getParameter(request,"referrer");

    if ("null".equals(referrer)) {
        referrer = null;
    }
    if (referrer == null) {
        referrer = request.getHeader("REFERER");
    }
    String createButton = ParamUtils.getParameter(request,"createButton");
    if ("取 消".equals(createButton)) {
        if (referrer == null) {
            referrer = "index.jsp";
        }
        response.sendRedirect(referrer);
        return;
    }

    // Error variables
    boolean errors = false;
	boolean errorUsername = false;
	boolean errorPassword = false;
	boolean errorConfirmPassword = false;
	boolean errorEmail = false;
	boolean errorName = false;
	boolean errorPasswordMatch = false;
    // User creation error vars
    boolean errorUserAlreadyExists = false;

    // Try creating a user account:
    if (create) {
        // Validate fields
        if (username == null || username.length() < 1) {
            errorUsername = true;
        }
        if (password == null || password.length() < 1) {
            errorPassword = true;
        }
        if (confirmPassword == null || confirmPassword.length() < 1) {
            errorConfirmPassword = true;
        }
        if (email == null) {
            errorEmail = true;
        }
        if (name == null) {
            errorName = true;
        }
        if (!errorPassword && !errorConfirmPassword) {
            if (!password.equals(confirmPassword)) {
                errorPasswordMatch = true;
            }
        }

        errors = errorUsername || errorPassword || errorConfirmPassword
                || errorEmail || errorName || errorPasswordMatch;

        // create an account if there were no errors
        if (!errors) {
		    try {
                UserManager userManager = myEnv.getForumFactory().getUserManager();
                User user = userManager.createUser(username, password, email);
                // Set the name
			    user.setName( name );
                // Set other properties
                if (location != null) {
                    user.setProperty("location", location);
                }
                if (occupation != null) {
                    user.setProperty("occupation", occupation);
                }
                if (homepage != null) {
                    user.setProperty("homepage", homepage);
                }
                // Log this user in
    			SkinUtils.login(request,response,username,password,autoLogin);
			    // redirect to main page
			    response.sendRedirect("accountSuccess.jsp");
			    return;
		    }
		    catch (UserAlreadyExistsException uaee) {
			    errors = true;
                errorUserAlreadyExists = true;
		    }
        }
    }
%>

<%  String title = "论坛 - 创建帐号"; %>
<%@ include file="header.jsp" %>

<% out.flush(); %>

<%-- Breadcrumbs --%>

<font face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>" color="<%= JiveGlobals.getJiveProperty("skin.default.linkColor") %>">
<b>
<a href="<%= JiveGlobals.getJiveProperty("skin.default.homeURL") %>"
>首页</a>
&raquo;
<a href="index.jsp" title="返回论坛列表"
>论坛</a>
&raquo;
<a href="account.jsp"
>创建帐号</a>
</b>
</font>
<p>

<font size="-1" face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">
您可以用下面的表单创建新帐号
<b>请注意:黑体标记的表格必须填写</b>
</font>

<p>

<%	if (create && errors) { %>
	<font size="-1" color="#ff0000" face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">
    <%  if (errorUserAlreadyExists) { %>
        很抱歉,这个用户名已经存在,请重新选择.
    <%  } else if (errorPasswordMatch) { %>
        您输入的密码不匹配.
    <%  } else { %>
        对不起,注册出现错误,请更正黑体标名的表格
        (<font color="#FF0000"><b>*</b></font>).
    <%  } %>
    </font>
    <p>
<%	}
%>

<form action="account.jsp" method="post" name="userForm">
<input type="hidden" name="create" value="true">
<input type="hidden" name="referrer" value="<%=referrer%>">

<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tr>
    <td align="right">
    <font size="-1" face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">
    <b>您的姓名:</b>
    <%  if (create && errorName) { %>
    <font color="#ff0000"><b>*</b></font>
    <%  } %>
    </font>
    </td>
    <td>
    <input type="text" name="name" size="30" maxlength="50" value="<%= (name!=null)?name:"" %>">
    <%  if (create && errorName) { %>
    <br>
    <font color="#ff0000" class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"
     >请输入姓名.</font>
    <%  } %>
    </td>
</tr>
<tr>
    <td align="right">
    <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">
    <b>Email:</b>
    <%  if (create && errorEmail) { %>
    <font color="#ff0000"><b>*</b></font>
    <%  } %>
    </font>
    </td>
    <td>
    <input type="text" name="email" size="30" maxlength="50" value="<%= (email!=null)?email:"" %>">
    <%  if (create && errorEmail) { %>
    <br>
    <font color="#ff0000" class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"
     >请输入一个有效的电子邮件地址.</font>
    <%  } %>
    </td>
</tr>
<tr>
    <td align="right">
    <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">
    <b>用 户 名:</b>
    <%  if (create && errorUsername) { %>
    <font color="#ff0000"><b>*</b></font>
    <%  } %>
    </font>
    </td>
    <td>
    <input type="text" name="username" size="30" maxlength="50" value="<%= (username!=null)?username:"" %>">
    <%  if (create && errorUsername) { %>
    <br>
        <font color="#ff0000" class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"
     >您的用户名至少2个字符.</font>
        <%  } %>
    </td>
</tr>
<tr>
    <td align="right">
    <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">
    <b>密  码:</b>
    <%  if (create && (errorPassword || errorPasswordMatch)) { %>
    <font color="#ff0000"><b>*</b></font>
    <%  } %>
    </font>
    </td>
    <td>
    <input type="password" name="password" size="15" maxlength="50" value="<%= (password!=null)?password:"" %>">
    <%  if (create && errorName) { %>
    <br>
        <font color="#ff0000" class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"
     >您的密码至少2个字符.</font>
        <%  } %>
    </td>
</tr>
<tr>
    <td align="right">
    <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">
    <b>确认密码:</b>
    <%  if (create && (errorConfirmPassword || errorPasswordMatch)) { %>
    <font color="#ff0000"><b>*</b></font>
    <%  } %>
    </font>
    </td>
    <td>
    <input type="password" name="confirmPassword" size="15" maxlength="50" value="<%= (confirmPassword!=null)?confirmPassword:"" %>">
    </td>
</tr>
<tr>
    <td align="right">
    <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">
    您的地址:
    </font>
    </td>
    <td>
    <input type="text" name="location" size="30" maxlength="50" value="<%= (location!=null)?location:"" %>">
    </td>
</tr>
<tr>
    <td align="right">
    <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">
    您的职业:
    </font>
    </td>
    <td>
    <input type="text" name="occupation" size="30" maxlength="50" value="<%= (occupation!=null)?occupation:"" %>">
    </td>
</tr>
<tr>
    <td align="right">
    <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">
    您的主页:
    </font>
    </td>
    <td>
    <input type="text" name="homepage" size="30" maxlength="50" value="<%= (homepage!=null)?homepage:"" %>">
    </td>
</tr>
<tr>
    <td align="center" colspan="2">
    <br>
    <input type="submit" name="createButton" value="创建帐号">
    <input type="submit" name="createButton" value="取 消">
    </td>
</tr>
</table>
<script language="JavaScript" type="text/javascript">
<!--
document.userForm.name.focus();
//-->
</script>
</form>

<br>

<%@ include file="footer.jsp" %>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -