【JSP开源代码栏目提醒】:以下是网学会员为您推荐的JSP开源代码-epaperAdmin.jsp,希望本篇文章对您学习有所帮助。
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%
// *** Logout the current user.
String MM_Logout = request.getRequestURI() + "?MM_Logoutnow=1";
if (request.getParameter("MM_Logoutnow") != null && request.getParameter("MM_Logoutnow").equals("1")) {
session.putValue("MM_Username", "");
session.putValue("MM_UserAuthorization", "");
String MM_logoutRedirectPage = "epaper.jsp";
// redirect with URL parameters (remove the "MM_Logoutnow" query param).
if (MM_logoutRedirectPage.equals("")) MM_logoutRedirectPage = request.getRequestURI();
if (MM_logoutRedirectPage.indexOf("?") == -1 && request.getQueryString() != null) {
String MM_newQS = request.getQueryString();
String URsearch = "MM_Logoutnow=1";
int URStart = MM_newQS.indexOf(URsearch);
if (URStart >= 0) {
MM_newQS = MM_newQS.substring(0,URStart) + MM_newQS.substring(URStart + URsearch.length());
}
if (MM_newQS.length() > 0) MM_logoutRedirectPage += "?" + MM_newQS;
}
response.sendRedirect(response.encodeRedirectURL(MM_logoutRedirectPage));
return;
}
%>
<%@ include file="Connections/connPaper.jsp" %>
<%
// *** Restrict Access To Page: Grant or deny access to this page
String MM_authorizedUsers="";
String MM_authFailedURL="epaper.jsp";
boolean MM_grantAccess=false;
if (session.getValue("MM_Username") != null && !session.getValue("MM_Username").equals("")) {
if (true || (session.getValue("MM_UserAuthorization")=="") ||
(MM_authorizedUsers.indexOf((String)session.getValue("MM_UserAuthorization")) >=0)) {
MM_grantAccess = true;
}
}
if (!MM_grantAccess) {
String MM_qsChar = "?";
if (MM_authFailedURL.indexOf("?") >= 0) MM_qsChar = "&";
String MM_referrer = request.getRequestURI();
if (request.getQueryString() != null) MM_referrer = MM_referrer + "?" + request.getQueryString();
MM_authFailedURL = MM_authFailedURL + MM_qsChar + "accessdenied=" + java.net.URLEncoder.encode(MM_referrer);
response.sendRedirect(response.encodeRedirectURL(MM_authFailedURL));
return;
}
%>
<%
Driver DriverRecList = (Driver)Class.forName(MM_connPaper_DRIVER).newInstance();
Connection ConnRecList = DriverManager.getConnection(MM_connPaper_STRING,MM_connPaper_USERNAME,MM_connPaper_PASSWORD);
PreparedStatement StatementRecList = ConnRecList.prepareStatement("SELECT * FROM epaper.epaperlist");
ResultSet RecList = StatementRecList.executeQuery();
boolean RecList_isEmpty = !RecList.next();
boolean RecList_hasData = !RecList_isEmpty;
Object RecList_data;
int RecList_numRows = 0;
%>
<%
Driver DriverRecPaper = (Driver)Class.forName(MM_connPaper_DRIVER).newInstance();
Connection ConnRecPaper = DriverManager.getConnection(MM_connPaper_STRING,MM_connPaper_USERNAME,MM_connPaper_PASSWORD);
PreparedStatement StatementRecPaper = ConnRecPaper.prepareStatement("SELECT * FROM epaper.epaper ORDER BY ep_date DESC");
ResultSet RecPaper = StatementRecPaper.executeQuery();
boolean RecPaper_isEmpty = !RecPaper.next();
boolean RecPaper_hasData = !RecPaper_isEmpty;
Object RecPaper_data;
int RecPaper_numRows = 0;
%>
<%
int Repeat1__numRows = 10;
int Repeat1__index = 0;
RecPaper_numRows += Repeat1__numRows;
%>
<%
// *** Recordset Stats, Move To Record, and Go To Record: declare stats variables
int RecPaper_first = 1;
int RecPaper_last = 1;
int RecPaper_total = -1;
if (RecPaper_isEmpty) {
RecPaper_total = RecPaper_first = RecPaper_last = 0;
}
//set the number of rows displayed on this page
if (RecPaper_numRows == 0) {
RecPaper_numRows = 1;
}
%>
<%
// *** Recordset Stats, Move To Record, and Go To Record: declare stats variables
int RecList_first = 1;
int RecList_last = 1;
int RecList_total = -1;
if (RecList_isEmpty) {
RecList_total = RecList_first = RecList_last = 0;
}
//set the number of rows displayed on this page
if (RecList_numRows == 0) {
RecList_numRows = 1;
}
%>
<%
// *** Recordset Stats: if we don't know the record count, manually count them
if (RecPaper_total == -1) {
// count the total records by iterating through the recordset
for (RecPaper_total = 1; RecPaper.next(); RecPaper_total++);
// reset the cursor to the beginning
RecPaper.close();
RecPaper = StatementRecPaper.executeQuery();
RecPaper_hasData = RecPaper.next();
// set the number of rows displayed on this page
if (RecPaper_numRows < 0 || RecPaper_numRows > RecPaper_total) {
RecPaper_numRows = RecPaper_total;
}
// set the first and last displayed record
RecPaper_first = Math.min(RecPaper_first, RecPaper_total);
RecPaper_last = Math.min(RecPaper_first + RecPaper_numRows - 1, RecPaper_total);
}
%>
<%
// *** Recordset Stats: if we don't know the record count, manually count them
if (RecList_total == -1) {
// count the total records by iterating through the recordset
for (RecList_total = 1; RecList.next(); RecList_total++);
// reset the cursor to the beginning
RecList.close();
RecList = StatementRecList.executeQuery();
RecList_hasData = RecList.next();
// set the number of rows displayed on this page
if (RecList_numRows < 0 || RecList_numRows > RecList_total) {
RecList_numRows = RecList_total;
}
// set the first and last displayed record
RecList_first = Math.min(RecList_first, RecList_total);
RecList_last = Math.min(RecList_first + RecList_numRows - 1, RecList_total);
}
%>
<% String MM_paramName = ""; %>
<%
// *** Move To Record and Go To Record: declare variables
ResultSet MM_rs = RecPaper;
int MM_rsCount = RecPaper_total;
int MM_size = RecPaper_numRows;
String MM_uniqueCol = "";
MM_paramName = "";
int MM_offset = 0;
boolean MM_atTotal = false;
boolean MM_paramIsDefined = (MM_paramName.length() != 0 && request.getParameter(MM_paramName) != null);
%>
<%
// *** Move To Record: handle 'index' or 'offset' parameter
if (!MM_paramIsDefined && MM_rsCount != 0) {
//use index parameter if defined, otherwise use offset parameter
String r = request.getParameter("index");
if (r==null) r = request.getParameter("offset");
if (r!=null) MM_offset = Integer.parseInt(r);
// if we have a record count, check if we are past the end of the recordset
if (MM_rsCount != -1) {
if (MM_offset >= MM_rsCount || MM_offset == -1) { // past end or move last
if (MM_rsCount % MM_size != 0) // last page not a full repeat region
MM_offset = MM_rsCount - MM_rsCount % MM_size;
else
MM_offset = MM_rsCount - MM_size;
}
}
//move the cursor to the selected record
int i;
for (i=0; RecPaper_hasData && (i < MM_offset || MM_offset == -1); i++) {
RecPaper_hasData = MM_rs.next();
}
if (!RecPaper_hasData) MM_offset = i; // set MM_offset to the last possible record
}
%>
<%
// *** Move To Record: if we dont know the record count, check the display range
if (MM_rsCount == -1) {
// walk to the end of the display range for this page
int i;
for (i=MM_offset; RecPaper_hasData && (MM_size < 0 || i
上一篇:
epaperAdd.jsp
下一篇:
网络能耗监测系统管理端的研究与实现