I. Purpose:
Through the comparison between ASP and JSP for the same function processing, research and implement the conversion from ASP to JSP. From the perspective of practical application, we have selected some representative database-related functions, including three specific functions: Query, add, and delete.
Ii. Page Features:
1. Database names and table names are shared)
- database name:pdtdb
- table name:pdtinfotable
Used table structure sharing)
- create table pdtinfotable
- (
- ID char(20) not null,
- ProductName char(20) ,
- primary key(ID)
- )
2. Function Description on each page
The first index and addaction use two pages:
- 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"
The second search uses one page:
- select * from table where ID= parameter "ID" or ProductName= paramenter "ProductName"
- submit "ID" and "ProductName"
The third delete and deleteaction use two pages:
- delete: select * from table
Each row is followed by another hyperlink chain to deleteaction ).
- deleteaction: delete from pdtinfo where ID= parameter "ID" ,go back "delete"
3. JavaBean
Use tax. mydb. class
Iii. Code comparison:
ASP to 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 to 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 to 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 to 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 to 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
- Comparison of syntax and object: view the convertible functions of ASP and JSP
- Technical Comparison of ASP and JSP Functions
- How to add a web framework in Servlet
- What are servlets and common Servlet APIs?
- At the beginning of JSP Servlet Development