xszs.jsp
来自「--- --^_^-------------- 广师公寓中心 1.请装上」· JSP 代码 · 共 265 行
JSP
265 行
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page language="java" import="java.sql.*" %>
<%
int counter=0;
Cookie cookies[]=request.getCookies();
if(cookies!=null){
for(int i=0;i<cookies.length;i++){
if(cookies[i].getName().equals("counter"))
counter=Integer.parseInt(cookies[i].getValue());
}
}
%>
<%
if(session.getAttribute("login1")== null)
{%>
<jsp:forward page="loginxszs.jsp"/>
<%}
%>
<%!
String sql="";
String key="";
String type="";
%>
<%
request.setCharacterEncoding("gb2312");
sql="SELECT * FROM student where name='fdsfewrdfasdfdf' ";
key=request.getParameter("m_key");
type=request.getParameter("m_type");
%>
<html>
<head>
<title>宿舍查询</title>
<style type="text/css">
<!--
table {
font-family: "宋体";
font-size: 14px;
color: #000000;
}
.unnamed1 {
border-bottom-width: 1px;
border-bottom-style: dashed;
border-bottom-color: #333333;
border-top-width: 1px;
border-top-style: dashed;
border-top-color: #000099;
}
.unnamed2 {
border-left-width: thin;
border-left-style: dashed;
border-left-color: #000000;
}
.style1 {
font-family: "隶书";
font-size: 18px;
}
.style2 {font-size: 24px}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="images/background.gif">
<SCRIPT LANGUAGE=JavaScript>
<!-- Begin
if (window.print) {
document.write('<form>'
+ '<input type=button name=print value=打印 '
+ 'onClick=javascript:window.print()></form>');
}
// End -->
</script>
<!-- ImageReady Slices (glry) -->
<table id="__01" width="680" height="425" border="0" cellpadding="0" cellspacing="0" align="center" background="images/glry_11.gif">
<!--DWLayoutTable-->
<tr>
<td height="55" colspan="6">
<img src="images/glry_01.gif" width="680" height="55" alt=""></td>
</tr>
<tr>
<td height="46" colspan="6">
<img src="images/glry_02.gif" width="680" height="46" alt=""></td>
</tr>
<tr>
<td height="41" colspan="6">
<img src="images/glry_03.gif" width="680" height="41" alt=""></td>
</tr>
<tr>
<td colspan="6" background="images/glry_04.gif" height="20" alt="">
<font color="#FF0000" size="2"><jsp:include page="time.htm"/>
<%
if(counter==0){
//if(session.getAttribute("counter1") == null){
out.print("欢迎首次光临!");
}
else{
out.print("今天您已经光临了"+counter+"次!");
//out.print("您已经光临了"+session.getAttribute("counter1")+"次!");
}
%></font></td>
</tr>
<tr>
<td width="115" height="19">
<a href="gongyu.jsp"><img src="images/glry_05.gif" alt="" width="115" height="19" border="0"></a></td>
<td width="113">
<a href="ry.jsp"><img src="images/glry_06.gif" alt="" width="113" height="19" border="0"></a></td>
<td width="112">
<a href="xszs.jsp"><img src="images/glry_07.gif" alt="" width="112" height="19" border="0"></a></td>
<td width="113">
<a href="wh.jsp"><img src="images/glry_08.gif" alt="" width="113" height="19" border="0"></a></td>
<td width="113">
<a href="lx.jsp"><img src="images/glry_09.gif" alt="" width="113" height="19" border="0"></a></td>
<td width="114">
<a href="hd.jsp"><img src="images/glry_10.gif" alt="" width="114" height="19" border="0"></a></td>
</tr>
<tr>
<td height="20" colspan="6" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="unnamed1">
<!--DWLayoutTable-->
<tr>
<td width="556" height="20" valign="top"><a href="gongyu.jsp">首页</a>>>宿舍查询 </td>
<td width="124" valign="top"><a href="zhexiao.jsp">注销<%=session.getAttribute("username")%></a></td>
</tr>
</table></td>
</tr>
<tr>
<td height="167" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="115" height="21" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td height="28" valign="top"><font color="#FF0000" size="+1"><%=session.getAttribute("username")%></font>同学<br>已登录<br><a href="zhexiao.jsp">注销<%=session.getAttribute("username")%></a></td>
</tr>
<tr>
<td height="96"> </td>
</tr>
</table></td>
<td colspan="5" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="unnamed2">
<!--DWLayoutTable-->
<tr>
<td width="564" height="14"> </td>
</tr>
<tr>
<td height="43" valign="top"><div align="center"><form action="xszs.jsp" method="post">
<div align="left"> 查询关键字:
<input type="text" name="m_key" width="75">
请选择查找操作字段:
<select name="m_type">
<option value="xuehao">学号</option>
<option value="name">姓名</option>
<option value="age">年龄</option>
<option value="sex">性别</option>
<option value="zhuanye">专业</option>
<option value="build">哪栋</option>
<option value="sushe">宿舍</option>
</select>
<input type="image" src="images/chakan.gif">
</div>
</form>
</div></td>
</tr>
<tr>
<td height="14"> </td>
</tr>
<tr>
<td height="95" valign="top">
<table width="100%" cellpadding="0" cellspacing="0" bordercolorlight="#0033FF" bordercolordark="#0033FF">
<!--DWLayoutTable-->
<tr>
<td width="13" height="31"> </td>
<td width="55"> </td>
<td colspan="5" valign="top"><div align="center" class="style1"> <span class="style2">以下是查询结果:</span></div></td>
<td width="136"> </td>
</tr>
<tr>
<td height="31"> </td>
<td colspan="2" valign="top"> 学号</td>
<td width="93" valign="top">姓名</td>
<td width="38" valign="top">年龄</td>
<td width="41" valign="top">性别</td>
<td width="109" valign="top">专业</td>
<td valign="top">宿舍</td>
</tr>
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e)
{
out.print(e);
}
try{
String strDirPath=application.getRealPath(request.getRequestURI());
strDirPath=strDirPath.substring(0,strDirPath.lastIndexOf('\\'))+"\\";
strDirPath=application.getRealPath("ODBC/gongyu.mdb");
String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+strDirPath;
Connection conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement();
if(request.getParameter("del")!=null)stmt.executeUpdate("delete * FROM student where id="+request.getParameter("del"));
if(key != null && type != null)
sql ="SELECT * FROM student where " +type+ " like '%"+key+"%'";
ResultSet rs = stmt.executeQuery(sql);
int xuehao=0;
String name="";
int age=0;
String sex="";
String zhunye="";
String build="";
int sushe=0;
while(rs.next()){
int id=rs.getInt("id");
xuehao=rs.getInt("xuehao");
name=rs.getString("name");
age=rs.getInt("age");
sex=rs.getString("sex");
zhunye=rs.getString("zhuanye");
build=rs.getString("build");
sushe=rs.getInt("sushe");
%>
<tr>
<td height="31"> </td>
<td colspan="2" valign="top"> <%=xuehao%></td>
<td valign="top"><%=name%></td>
<td valign="top"><%=age%></td>
<td valign="top"><%=sex%></td>
<td valign="top"><%=zhunye%></td>
<td valign="top"><%=build%><%=sushe%></td>
</tr>
<tr>
<td height="0"></td>
<td></td>
<td width="54"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<%}
rs.close();
stmt.close();
conn.close();
}
catch(Exception ex)
{
out.print(ex);
}
%>
</table></td>
</tr>
<tr>
<td height="1"></td>
</tr>
</table></td>
</tr>
<tr>
<td height="48" colspan="6">
<img src="images/glry_12.gif" width="680" height="48" alt=""></td>
</tr>
</table>
<!-- End ImageReady Slices -->
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?