JSP permission control source code

Source: Internet
Author: User

JSP permission control source code


By accident, I learned a piece of code when I first learned Java many years ago. Maybe I can't write it now. If the technology is so popular, it will move back if it is not in progress. It's still good to be young, with clear ideas and ample energy.

[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". Define signorecase (action ))
{// Member Logon: Authenticate the user identity and set the Session variable and logon flag
// Obtain logon Parameters
String userName = request. getParameter ("username ");
String userPwd = request. getParameter ("password ");
System. out. println ("account:" + userName + "Password:" + userPwd );
If (userName = null | userName = "" | userPwd = null | userPwd = "")
{// The request parameter is invalid.
%>
<Script language = "javascript">
Alert ("no required Request Parameters for member login! ");
Window. history. go (-1 );
</Script>
<%
}
Else
{// The parameter is valid
If (permitBean. memberLogin (userName, userPwd ))
{// Logon successful
// Chengxiaoxu 2004-05-25 remark code in here to best
Session. setAttribute ("sessionPermit", permitBean );
PermitBean ssnPermit = (PermitBean) session. getAttribute ("sessionPermit ");

String strLogin = ssnPermit. getIsLogin ()? "Logon successful! ":" Logon Failed ??? ";
String ackName = ssnPermit. getMgrAckName ();
System. out. println ("member account:" + strLogin + "\ n" + ackName );
If (memberBean. getBeanInfoByID (ssnPermit. getMemberID ()))
{
System. out. println ("member information extracted! ");
Session. setAttribute ("sessionMember", memberBean );
}

%>
<Script language = "javascript">
// Alert ("<% = strLogin %> ");
// Alert ("<% = permitBean. getMsg () %> ");
// Uses tar get = "_ blank ";
// The homepage of the member Management Center is displayed.
Window. location = "membermain. jsp ";
</Script>
<%
}
Else
{// Logon Failed
%>
<Script language = "javascript">
Alert ("<% = permitBean. getMsg () %> ");
Window. history. go (-1 );
</Script>
<%
} // End of <Logon Failed>
} // End of <the parameter is valid>
%>
<%
} // End of <member logon>
Else if ("update". cancsignorecase (action ))
{// Modify the member Password
// Obtain the modified Parameters
String oldPwd = request. getParameter ("oldPassword ");
String newPwd = request. getParameter ("newPassword1 ");
If (oldPwd = null | oldPwd = "" | newPwd = null | newPwd = "")
{// The request parameter is invalid.
%>
<Script language = "javascript">
Alert ("no data to modify required Request Parameters! ");
Window. history. go (-1 );
</Script>
<%
} // End of <The request parameter is invalid>
Else
{// The parameter is valid
%>
<%
Boolean isOK = permitBean. changePassword (String) session. getAttribute ("sessionUserAccount"), oldPwd, newPwd); www.2cto.com
%>
<Script language = "javascript"> alert ("<% = permitBean. getMsg () %>"); </script>
<%
If (isOK)
{// Modification successful
%>
<Script language = "javascript"> window. location = "membermain. jsp"; </script>
<%
}
Else {// modification failed
%>
<Script language = "javascript"> window. history. go (-1); </script>
<%
}
 
} // End of <the parameter is valid>
%>
<%
} // End of <modify member password>
Else if ("logout". cancsignorecase (action ))
{// Member logout: clears the Session variable and the logon flag.
// 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? "Logout successful! ":" Logout failed ??? ";
 
%>
<Script language = "javascript">
// Alert ("<% = strLogin %> ");
Window. location = "main. jsp ";
</Script>
<%
}
Else
{// Incorrect page request
%>
<Script language = "javascript">
Alert ("invalid page request ");
Window. history. go (-1 );
</Script>
<%
} // End of <incorrect page request>
%>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.