【JSP开源代码栏目提醒】:网学会员,鉴于大家对JSP开源代码十分关注,论文会员在此为大家搜集整理了“epaperDel.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="epaperAdmin.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;
}
%>
<%
// *** Edit Operations: declare variables
// set the form action variable
String MM_editAction = request.getRequestURI();
if (request.getQueryString() != null && request.getQueryString().length() > 0) {
String queryString = request.getQueryString();
String tempStr = "";
for (int i=0; i < queryString.length(); i++) {
if (queryString.charAt(i) == '<') tempStr = tempStr + "<";
else if (queryString.charAt(i) == '>') tempStr = tempStr + ">";
else if (queryString.charAt(i) == '"') tempStr = tempStr + """;
else tempStr = tempStr + queryString.charAt(i);
}
MM_editAction += "?" + tempStr;
}
// connection information
String MM_editDriver = null, MM_editConnection = null, MM_editUserName = null, MM_editPassword = null;
// redirect information
String MM_editRedirectUrl = null;
// query string to execute
StringBuffer MM_editQuery = null;
// boolean to abort record edit
boolean MM_abortEdit = false;
// table information
String MM_editTable = null, MM_editColumn = null, MM_recordId = null;
// form field information
String[] MM_fields = null, MM_columns = null;
%>
<%
// *** Delete Record: construct a sql delete statement and execute it
if (request.getParameter("MM_delete") != null &&
request.getParameter("MM_delete").toString().equals("form1") &&
request.getParameter("MM_recordId") != null) {
MM_editDriver = MM_connPaper_DRIVER;
MM_editConnection = MM_connPaper_STRING;
MM_editUserName = MM_connPaper_USERNAME;
MM_editPassword = MM_connPaper_PASSWORD;
MM_editTable = "epaper.epaper";
MM_editColumn = "ep_id";
MM_recordId = "" + request.getParameter("MM_recordId") + "";
MM_editRedirectUrl = "epaperAdmin.jsp";
// append the query string to the redirect URL
if (MM_editRedirectUrl.length() != 0 && request.getQueryString() != null) {
MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + request.getQueryString();
}
}
%>
<%
// *** Delete Record: construct a sql delete statement and execute it
if (request.getParameter("MM_delete") != null &&
request.getParameter("MM_recordId") != null) {
// create the delete sql statement
MM_editQuery = new StringBuffer("delete from ").append(MM_editTable);
MM_editQuery.append(" where ").append(MM_editColumn).append(" = ").append(MM_recordId);
if (!MM_abortEdit) {
// finish the sql and execute it
Driver MM_driver = (Driver)Class.forName(MM_editDriver).newInstance();
Connection MM_connection = DriverManager.getConnection(MM_editConnection,MM_editUserName,MM_editPassword);
PreparedStatement MM_editStatement = MM_connection.prepareStatement(MM_editQuery.toString());
MM_editStatement.executeUpdate();
MM_connection.close();
// redirect with URL parameters
if (MM_editRedirectUrl.length() != 0) {
response.sendRedirect(response.encodeRedirectURL(MM_editRedirectUrl));
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;
%>
<%
String RecPaper__MMColParam = "1";
if (request.getParameter("ep_id") !=null) {RecPaper__MMColParam = (String)request.getParameter("ep_id");}
%>
<%
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 WHERE ep_id = " + RecPaper__MMColParam + "");
ResultSet RecPaper = StatementRecPaper.executeQuery();
boolean RecPaper_isEmpty = !RecPaper.next();
boolean RecPaper_hasData = !RecPaper_isEmpty;
Object RecPaper_data;
int RecPaper_numRows = 0;
%>
<%
// *** 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 (RecList_total == -1) {
// count the total records by iterating through the recordset
for (RecList_total = 1; RecList.next(); RecList_total++);
// re
上一篇:
epaperAdminList.jsp
下一篇:
关于广告设计人才培养模式研究