一、目的:
通过ASP与JSP对于相同功能处理的比较,研究和实现从ASP到JSP的转换。从实际应用考虑,我们选取了与数据库相关的一些有代表性的功能,包括三个具体功能:查询、添加以及删除。
二、页面功能介绍:
1. 数据库名称以及表名称(共用)
- database name:pdtdb
- table name:pdtinfotable
所用表结构(共用)
- create table pdtinfotable
- (
- ID char(20) not null,
- ProductName char(20) ,
- primary key(ID)
- )
2.各页面功能说明
第一个index,addaction用2个页面:
- index: select * from table
- submit insert value(ID, ProductName) go to "addaction"
- addaction: get parameter: "ID" and "ProductName";
- Do the "insert function " go back "index"
第二个search用1个页面 :
- select * from table where ID= parameter "ID" or ProductName= paramenter "ProductName"
- submit "ID" and "ProductName"
第三个delete,deleteaction用2个页面:
- delete: select * from table
每个行后面又一个超链接(链到deleteaction).
- deleteaction: delete from pdtinfo where ID= parameter "ID" ,go back "delete"
3.JavaBean
使用 tax.mydb.class
三、代码详细比较:
ASP到JSP,index:
- strConnection = "DSN=pdtdb;Database=pdtdb;"
- Set objConn=Server.CreateObject("ADODB.Connection")
- objConn.Open strConnection
- Set objRS=Server.CreateObject("ADODB.Recordset")
- Set objRS.ActiveConnection=objConn
ASP到JSP,addaction
- strConnection = "DSN=pdtdb;Database=pdtdb;"
- Set objConn=Server.CreateObject("ADODB.Connection")
- objConn.Open strConnection
- Set objRS=Server.CreateObject("ADODB.Recordset")
- Set objRS.ActiveConnection=objConn
ASP到JSP,search:
- strConnection = "DSN=pdtdb;Database=pdtdb;"
- Set objConn=Server.CreateObject("ADODB.Connection")
- objConn.Open strConnection
- Set objRS=Server.CreateObject("ADODB.Recordset")
- Set objRS.ActiveConnection=objConn
ASP到JSP,delete
- strConnection = "DSN=pdtdb;Database=pdtdb;"
- Set objConn=Server.CreateObject("ADODB.Connection")
- objConn.Open strConnection
- Set objRS=Server.CreateObject("ADODB.Recordset")
- Set objRS.ActiveConnection=objConn
ASP到JSP,deleteaction
- strConnection = "DSN=pdtdb;Database=pdtdb;"
- Set objConn=Server.CreateObject("ADODB.Connection")
- objConn.Open strConnection
- Set objRS=Server.CreateObject("ADODB.Recordset")
- Set objRS.ActiveConnection=objConn