利用JSP建立Web站点

王朝java/jsp·作者佚名  2006-12-16
窄屏简体版  字體: |||超大  

<HTML>

<HEAD>

<TITLE>新闻</TITLE>

<link REL="stylesheet" href="mycss.css"TYPE="text/css">

<META content="text/html; charset=GB2312"http-equiv=Content-Type>

<%@ page import="com.eprobiti.TRS.*"%>

<%@ page import="java.util.*"%>

<jsp:useBean id="TRSConn"scope ="session" class="com.eprobiti.TRS.TRSConnection"/>

<jsp:useBean id="TRSRS"scope ="page" class="com.eprobiti.TRS.TRSResultSet"/>

</HEAD>

<BODY>

<%

String item_id=request.getParameter("id");

//参数id由URL或者前一个文件的表单隐藏域传过来

String dbname,ip,port,username,password;

dbname="news.北京新闻";

//TRS数据库名字

ip="202.123.166.99"; //TRS服务器IP

port="8888";//TRS服务器端口

username="yourname";

// 可以检索"news.北京新闻"的用户名

password="yourpassword";

// 该用户名对应的口令

String filter="编号="+item_id;

//定义检索条件

try {

if (TRSConn.connect(ip,port,username,password)){ }

//建立与TRS服务器的连接

else {

out.println("Connection 连接失败!\n");

}

TRSRS=TRSConn.executeSelect(dbname,s1,"","", null, 0, 0, false);

// 执行查询操作,生成记录集

} catch(TRSException TRSe) {

out.println("ResultSet 连接失败!\n");

}

try {

TRSRS.moveFirst();

//记录定位

%>

<p>

<center>

<table width=80%>

<tr align=center>

<td><%=TRSRS.getString("标题")%>

</td>

</tr>

<tr align=center>

<td><%=TRSRS.getString("日期")%>

</td>

</tr>

<tr>

<td><%=TRSRS.getString("内容")%>

</td>

</tr>

</table>

</center>

<p>

<%

TRSRS.close();

} catch(TRSException TRSe) {}

%>

</body>

</html>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航