【JSP开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了JSP开源代码-AdminMenu.jsp的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
<%@ page contentType="text/html;charset=gb2312"%>
<%@ include file="Common.jsp" %><%!
//
// Filename: AdminMenu.jsp
static final String sFileName = "AdminMenu.jsp";
static final String PageBODY = "text=\"#000000\" link=\"#000080\" vlink=\"#000080\" alink=\"#000080\"";
static final String FormTABLE = "border=\"0\" cellspacing=\"2\" cellpadding=\"0\"";
static final String FormHeaderTD = "align=\"center\" bgcolor=\"#FFBB55\"";
static final String FormHeaderFONT = "style=\"font-size: 12pt; color: #FFFFFF; font-family: Arial, Tahoma, Verdana, Helvetica; font-weight: bold\"";
static final String FieldCaptionTD = "bgcolor=\"#FFDD00\"";
static final String FieldCaptionFONT = "style=\"font-size: 10pt; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica\"";
static final String DataTD = "";
static final String DataFONT = "style=\"font-size: 10pt; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica\"";
static final String ColumnFONT = "style=\"font-size: 10pt; color: #FFFFFF; font-family: Arial, Tahoma, Verdana, Helvetica; font-weight: bold\"";
static final String ColumnTD = "bgcolor=\"#000000\"";
%><%
String cSec = checkSecurity(3, session, response, request);
if ("sendRedirect".equals(cSec) ) return;
boolean bDebug = false;
String sAction = getParam( request, "FormAction");
String sForm = getParam( request, "FormName");
String sFormErr = "";
String sLoginErr = "";
java.sql.Connection conn = null;
java.sql.Statement stat = null;
String sErr = loadDriver();
conn = cn();
stat = conn.createStatement();
if ( ! sErr.equals("") ) {
try {
out.println(sErr);
}
catch (Exception e) {}
}
if ( sForm.equals("Login") ) {
sLoginErr = LoginAction(request, response, session, out, sAction, sForm, conn, stat);
if ( "sendRedirect".equals(sLoginErr)) return;
}
%>
<html>
<head>
<title>Employee Directory</title>
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="expires" content="0"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" link="#000080" vlink="#000080" alink="#000080">
<jsp:include page="Header.jsp" flush="true"/>
<table>
<tr>
<td valign="top">
<% Form_Show(request, response, session, out, sFormErr, sForm, sAction, conn, stat); %>
</td>
</tr>
</table>
<table>
<tr>
<td valign="top">
<% Login_Show(request, response, session, out, sLoginErr, sForm, sAction, conn, stat); %>
</td>
</tr>
</table>
</body>
</html>
<%%>
<%
if ( stat != null ) stat.close();
if ( conn != null ) conn.close();
%>
<%!
void Form_Show (javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpSession session, javax.servlet.jsp.JspWriter out, String sFormErr, String sForm, String sAction, java.sql.Connection conn, java.sql.Statement stat) throws java.io.IOException {
try {
out.println(" <table border=\"0\" cellspacing=\"2\" cellpadding=\"0\">");
out.println(" <tr>\n <td align=\"center\" bgcolor=\"#FFBB55\"><font style=\"font-size: 12pt; color: #FFFFFF; font-family: Arial, Tahoma, Verdana, Helvetica; font-weight: bold\">管理员功能</font></td>\n </tr>");
out.print(" <tr>");
// Set URLs
String fldField2 = "EmpsGrid.jsp";
String fldField1 = "DepsGrid.jsp";
// Show fields
out.print("\n <td ><a href=\""+fldField2+"\"><font style=\"font-size: 10pt; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica\">员工信息</font></a></td>\n\n </tr>\n\n <tr>");
out.print("\n <td ><a href=\""+fldField1+"\"><font style=\"font-size: 10pt; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica\">部门信息</font></a></td>");
out.println("\n </tr>\n </table>");
}
catch (Exception e) { out.println(e.toString()); }
}
String LoginAction(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpSession session, javax.servlet.jsp.JspWriter out, String sAction, String sForm, java.sql.Connection conn, java.sql.Statement stat) throws java.io.IOException {
String sLoginErr = "";
try {
final int iloginAction = 1;
final int ilogoutAction = 2;
String transitParams = "";
String sQueryString = "";
String sPage = "";
String sSQL="";
int iAction = 0;
if ( sAction.equals("login") ) iAction = iloginAction;
if ( sAction.equals("logout") ) iAction = ilogoutAction;
switch (iAction) {
case iloginAction: {
// Login action
String sLogin = getParam( request, "Login");
String sPassword = getParam( request, "Password");
java.sql.ResultSet rs = null;
rs = openrs( stat, "select emp_id, emp_level from emps where emp_login =" + toSQL(sLogin, adText) + " and emp_password=" + toSQL(sPassword, adText));
if ( rs.next() ) {
// Login and password passed
session.setAttribute("UserID", rs.getString(1));
session.setAttribute("UserRights", rs.getString(2));
sQueryString = getParam( request, "querystring");
sPage = getParam( request, "ret_page");
if ( ! sPage.equals(request.getRequestURI() ) && ! "".equals(sPage)) {
try {
if ( stat != null ) stat.close();
if ( conn != null ) conn.close();
}
catch ( java.sql.SQLException ignore ) {}
response.sendRedirect(sPage + "?" + sQueryString);
return "sendRedirect";
}
}
else sLoginErr = "Login or Password is incorrect.";
rs.close();
break;
}
case ilogoutAction: {
// Logout action
session.setAttribute("UserID", "");
session.setAttribute("UserRights", "");
break;
}
}
}
catch (Exception e) { out.println(e.toString()); }
return (sLoginErr);
}
void Login_Show(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpSession session, javax.servlet.jsp.JspWriter out, String sLoginErr, String sForm, String sAction, java.sql.Connection conn, java.sql.Statement stat) throws java.io.IOException {
try {
String sSQL="";
String transitParams = "";
String sQueryString = getParam( request, "querystring");
String sPage = getParam( request, "ret_page");
out.println(" <table border=\"0\" cellspacing=\"2\" cellpadding=\"0\" border=1>");
out.println(" <tr>\n <td align=\"center\" bgcolor=\"#FFBB55\" colspan=\"2\"><font style=\"font-size: 12pt; color: #FFFFFF; font-family: Arial, Tahoma, Verdana, Helvetica; font-weight: bold\">Login</font></td>\n </tr>");
if ( sLoginErr.compareTo("") != 0 ) {
out.println(" <tr>\n <td colspan=\"2\" ><font style=\"font-size: 10pt; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica\">"+sLoginErr+"</font></td>\n </tr>");
}
sLoginErr="";
out.println(" <form action=\""+sFileName+"\" method=\"POST\">");
out.println(" <input type=\"hidden\" name=\"FormName\" value=\"Login\">");
if ( session.getAttribute("UserID") == null || ((String) session.getAttribute("UserID")).compareTo("") == 0 ) {
// User did not login
out.println(" <tr>\n <td bgcolor=\"#FFDD00\"><font style=\"font-size: 10pt; color: #000000; font-family: Arial, Tahoma, Verdana, Helveti
上一篇:
adminMain.jsp
下一篇:
秋天是疼痛的