当前位置:编程学习 > JS >>

JSP权限控制源码

JSP权限控制源码


        偶然翻到很多年前,刚学Java的时候学的一段代码。或许,现在让写,还写不出来了。技术如潮、不进则退。还是年轻好啊,思路清晰、精神充沛。

[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"> 
       &nbs

补充:Web开发 , Jsp ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,