?? del.jsp
字號:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" %>
<jsp:useBean id="DBConnection" scope="page" class="com.guestbook.DBConnection"/>
<%
Boolean a=(Boolean)session.getAttribute("a");
Connection conn=conn=DBConnection.getConnectionToAccess(application.getRealPath("data/guestbook.mdb"));
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
if(a==null||a.booleanValue()==false)
{
%>
<script language=JavaScript>
alert('此頁面僅對站長開放!');
location.href="index.jsp"
</script>
<%
}else{
String id=request.getParameter("id");
String sqlr="delete from Guestbook where id=" +id;
try{
//out.print(sql);
stmt.executeUpdate(sqlr);
response.sendRedirect("index.jsp");
}
catch(Exception e){
response.sendRedirect("error.jsp?error=2");//數據庫更新出錯!
}
if(conn!=null)
{
conn.close();
}
if(stmt!=null)
{
stmt.close();
}
}
%>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -