jsp页面数据库数据输出问题,请大家指教,不胜感激!
我的jsp页面中的数据需要由数据库中的数据导入。首先说明数据库在另一台服务器上,我在我的客户机上安装了Jbuilder2006和Tomcat5.5,还有SQLServer2000 JDBC,在classpath环境变量中设置了JDK、tomcat、Jdbc,都安装测试成功。我写了一段代码,可是放到Tomcat的目录Tomcat 5.5\webapps\myjsp下,启动Tomcat 5.5,在地址然终输入http://我的ip/myjsp/database.jsp,页面时空白,没有输出数据库中的数据,不知道为什么?单独运行其中java代码是能够输出数据库中的数据的,请大家指教,不胜感激!
以下是我的代码:
<%@ page contentType= "text/html; charset=GBK " %>
<%@page import = "java.sql.* "%>
<%@ page import= "java.io.* " %>
<html>
<head>
<title>
database
</title>
</head>
<body bgcolor= "#ffffff ">
<%
String sql_driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver ";
String sql_url = "jdbc:microsoft:sqlserver://59.70.255.60:1433;DatabaseName=TermBank ";
String sql_DBName = "TermBank ";
String user = "sa ";
String pwd = " ";
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try{
Class.forName(sql_driver).newInstance();//load the database driver
conn = DriverManager.getConnection(sql_url,user,pwd);//(sql_url + "/ " + sql_DBName + "?user= " + user + "&password= " + pwd + "&useUnicode=true&characterEncoding=gb2312 ");
stmt = conn.createStatement();
String SQLStr= "select * from ecorpus where Chapter= '1 ' "+ " order by ID asc ";
StringBuffer secindex=new StringBuffer() ;
String id=new String() ;
String title=new String() ;
String efile=new String() ;
String cfile=new String() ;
try{
rs= stmt.executeQuery(SQLStr);
while(rs .next() )
{
id=rs.getString( "Section ");
id=id.replaceAll( "\r\n ", " ");
title=rs.getString( "Heading ");
title=title.replaceAll( "\r\n ", " ");
&nbs