代码如下:有用的只有中间那段:
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%@page import="java.sql.*"%>
<% request.setCharacterEncoding("gbk"); %>
<html>
<head>
<title>My JSP 'main1.jsp' starting page</title>
</head>
<body >
<%
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String strSQL = "";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException ce){
out.println(ce.getMessage());
}
%>
<br>
<table width="827" border="1" align="center">
<tr>
<td width="817" height="52" colspan="3"></td>
</tr>
</table>
<table width="827" border="1" align="center">
<tr>
<td width="817" height="174" colspan="3"> </td>
</tr>
</table>
<table width="832" border="1" align="center" >
<tr >
<td width="270" height="532" valign="top"><div align="left"><a href="classly.jsp" class="STYLE1">留言板</a> <a href="classly.jsp">more</a></div>
<p> </p>
<% try{
conn=DriverManager.getConnection("jdbc:odbc:liu1");
stmt=conn.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
strSQL = "SELECT * FROM classly";
rs = stmt.executeQuery(strSQL);
for(int i=1; i<=2; i++)
{
out.print(rs.getString("sno"));
out.println(rs.getString("title"));
if(!rs.next()) break;
}
}
catch(SQLException e){
System.out.println(e.getMessage());
}
finally{
rs.close();
stmt.close();
conn.close();
} %>
</td>
<td width="270" height="532"> </td>
<td width="270" height="532"> </td>
</tr>
</table>
<table width="828" border="0"align="center" background="11111.jpg">
<tr>