13 <%
14 Connection conn = null;
15 ResultSet rs = null;
16 String server = "......";
17 String port = "....";
18 String db ="....";
19 String user = "....";
20 String pass = ".....";
21 String drivername="com.mysql.jdbc.Driver";
22 String URL ,sqlcmd,institutionname;
23 String str_IdP="";
24
25 //get database connection
26 try{
27 Class.forName(drivername).newInstance();
28 URL="jdbc:mysql://"+server+":"+port+"/"+db+"?user="+user+"&password="+pass + "&useUnicode=true&charact erEncoding=utf8" ;
29 conn = DriverManager.getConnection(URL);
30
31 Statement stmt = conn.createStatement();
32 sqlcmd="select * from redapp;";
33 rs = stmt.executeQuery(sqlcmd);
34 %>
35 <script language="JavaScript">
36 //处理不同浏览器下的兄弟节点访问的函数
37 var getNextSibling = function(obj){
38 if(obj.nextSibling.nodeType==3) {
39 sibling=obj.nextSibling.nextSibling; // Moz. Opera
40 }
41 else {
42 sibling=obj.nextSibling; // IE
43 }
44 return sibling;
45 };
46 //生成Javascript代码
47 <%
48 while(rs.next())
49 {
50 institutionname=rs.getString("institutionname");
51 out.println("var td_node=document.getElementById(\""+institutionname+"\");");
52 out.println("getNextSibling(td_node).innerHTML+=\"<a href=\\\""+rs.getString("url")+"\\\" target=_top>"+rs.getString("description")+"</a> \";");
53 }
54 %>
55 </script>
56 <%
57 rs.close();
58 rs = null;
59
60 conn.close();
61 conn = null;
62
63 }catch(Exception e){
64 e.printStackTrace();
65 }
66 %>
|