JSP权限控制
[java]
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="qlsoft.PWebs.Business.PermitBean" %>
<jsp:useBean id="permitBean" scope="session" class="qlsoft.PWebs.Business.PermitBean" />
<%@ page import="qlsoft.PWebs.Business.MemberBean" %>
<jsp:useBean id="memberBean" scope="session" class="qlsoft.PWebs.Business.MemberBean" />
<%
String action= request.getParameter("action");
%>
<script language="javascript">
//alert("Permit request action:" + "<%=action%>");
</script>
<%
if("login".equalsIgnoreCase(action))
{//会员登录:验证用户身份,并设置Session变量及已登录标志
//获取登录参数
String userName= request.getParameter("username");
String userPwd= request.getParameter("password");
System.out.println("帐号:" + userName + "密码:" + userPwd);
if(userName == null || userName == "" || userPwd == null || userPwd == "")
{//请求的参数无效
%>
<script language="javascript">
alert("没有会员登录必须的请求参数!");
window.history.go(-1);
</script>
<%
}
else
{//参数有效
if(permitBean.memberLogin(userName,userPwd))
{//登录成功
//chengxiaoxu 2004-05-25 remark code in here to best
session.setAttribute("sessionPermit",permitBean);
PermitBean ssnPermit = (PermitBean)session.getAttribute("sessionPermit");
String strLogin = ssnPermit.getIsLogin() ? "登录成功!" : "登录失败???";
String ackName = ssnPermit.getMgrAckName();
System.out.println("会员帐号:" + strLogin + "\n" + ackName);
if(memberBean.getBeanInfoByID(ssnPermit.getMemberID()))
{
System.out.println("提取会员信息成功!");
session.setAttribute("sessionMember",memberBean);
}
%>
<script language="javascript">
//alert("<%=strLogin %>");
//alert("<%=permitBean.getMsg() %>");
//window.target="_blank";
//此处完成后应该是会员管理中心主页面
window.location="membermain.jsp";
</script>
<%
}
else
{//登录失败
%>
<script language="javascript">
alert("<%=permitBean.getMsg() %>");
window.history.go(-1);
</script>
<%
}//End of <登录失败>
}//End of <参数有效>
%>
<%
}//End of <会员登录>
else if("update".equalsIgnoreCase(action))
{//修改会员密码
//获取修改参数
String oldPwd= request.getParameter("oldPassword");
String newPwd= request.getParameter("newPassword1");
if(oldPwd == null || oldPwd == "" || newPwd == null || newPwd == "")
{//请求的参数无效
%>
<script language="javascript">
alert("没有资料修改必须的请求参数!");
window.history.go(-1);
</script>
<%
}//End of <请求的参数无效>
else
{//参数有效
%>
<%
boolean isOK = permitBean.changePassword((String)session.getAttribute("sessionUserAccount"),oldPwd,newPwd); www.2cto.com
%>
<script language="javascript">alert("<%=permitBean.getMsg() %>");</script>
<%
if(isOK)
{//修改成功
%>
<script language="javascript">window.location="membermain.jsp";</script>
<%
}
else{//修改失败
%>
<script language="javascript">window.history.go(-1);</script>
<%
}
}//End of <参数有效>
%>
<%
}//End of <修改会员密码>
else if("logout".equalsIgnoreCase(action))
{//会员注销:清空Session变量及已登录标志
//chengxiaoxu 2004-05-25 update code in here to best
if(permitBean != null)
permitBean.memberLogout();
session.setAttribute("sessionPermit",null);
session.setAttribute("sessionMember",null);
PermitBean ssnPermit = (PermitBean)session.getAttribute("sessionPermit");
String strLogin = ssnPermit==null ? "注销成功!" : "注销失败???";
%>
<script language="javascript">
//alert("<%=strLogin %>");
window.location="main.jsp";
</script>
<%
}
else
{//错误的页面请求
%>
<script language="javascript">
alert("无效的页面请求");
window.history.go(-1);
</script>
<%
}//End of <错误的页面请求>
%>
推荐阅读
-
thinkPHP网站某些控制器sql实施效率低,用什么方法监测出哪条sql导致的
-
JSP权限控制
-
jsp servlet过滤jsp后缀_html/css_WEB-ITnose
-
php控制文件下载速度的方法,_PHP教程
-
Codeigniter中mkdir创建目录遇到权限问题和解决方法,codeignitermkdir_PHP教程
-
使用js实现按钮控制文本框加1减1应用于小时+分钟_javascript技巧
-
nginx访问控制的两种方法
-
WIN2008 R2 Active Directory 之二 部署企业中Windows Server 2008 R2额外域控制器
-
Oracle for Linux 双机 控制文件报错问题
-
关于linux下建站目录分配权限的示例代码分享