JSP (Java Server Page) and ASP (Active Server Page) are both common dynamic web pages and can be embedded into HTML programs. JSP programming ideas are similar to ASP. However, there are essential differences between the two, mainly from the following aspects:
1) Web Server support: most common Web servers, such as Apache, Netscape, and Microsoft IIS, support JSP pages. Only Microsoft IIS and Personal Web Server support ASP.
2) platform support: JSP is platform independent. As long as it is a platform that can run general Java programs, JSP programs are supported. The Windows platform can support ASP well. However, the dependency of ASP on Win32-based models makes it difficult for other platforms.
3) Component Model: JSP is built on reusable and cross-platform components, such as JavaBeans, Enterprises JavaBeans, and custom tag libraries, ASP uses the Win32-based COM component model.
4) scripting language: JSP can use Java programming language or JavaScript as the scripting language, while ASP uses VBScript or Jscript as the scripting language.
5) Security: JSP uses the Java security model, while ASP uses the security structure of Windows NT.
6) connection to the Access Database: JSP uses JDBC to establish a connection with the Access database, while ASP uses Data Active Objects for the Access database.
7) custom tags: JSP can be expanded using the custom tag library. ASP cannot be expanded without the custom tag library in ASP.
The following program has a general FRAME function. In fact, you can add some functions by yourself. For example, to start Datcbase connection, you can set the variable and then use INIT () to select Datcbase of different types.
- <%
- 'On Error Resume Next
- Class ConnEx
- PubliC ConnEx
- PubliC DBpath '--------- Datcbase path
- PubliC DBtype '--------- DatcbaseTYPE 1 (ACCess) 2 (SqlServer) 3 (expandable)
- PubliC ConnMethod '-------- connection method DSN, non-DSN)
- PubliC User
- PubliC Pass
- Sub Class_initialize
- End Sub
-
- Sub Init ()
- ConnStr="Driver = {MiCrosoft ACCess Driver (*. mdb)}; dbq ="& Server. MapPath ("Date. mdb ")
- SetConnEx=Server. CreateobjeCt ("ADODB. CONNECTION ")
- ConnEx. Open ConnStr
- CatChError ("Class_Terminate ")
- End Sub
-
- Sub CatChError (Str)
- If Err Then
- Err. Clear
- Class_Terminate ()
- Response. Write ("caught error, program ended! At "& Str ")
- Response. End ()
- End If
- End Sub
-
- '*************************************** ***
- '* You can use SQL statements to check whether a record exists, which is prone to errors.
- '*************************************** ***
-
- FunCtion HasReCordBySql (SQL)
- Call CheCkSql (SQL, "R ")
- Dim Rs, HasR
- SetRs=ConnEx. ExeCute (SQL)
- CatChError ("HasReordSql ")
- If Not (Rs. eof Or Rs. bof) Then
- HasR=False
- Else
- HasR=True
- End If
- Rs. Close
- SetRs=Nothing
- HasRHasReCordBySql= HasR
- End FunCtion
-
- '***************************************
- '* Use ID to check whether a record exists
- '***************************************
-
- FunCtion HasReCordById (StrTableName, IntID)
- 'Checkvalue (IntID, 1)
- Dim Rs, HasR
- SQL="SeleCt top 1 * from"& StrTableName & "WhereId= "& IntID
- Call CheCkSql (SQL, "R ")
- SetRs=ConnEx. ExeCute (SQL)
- CatChError ("HasReCordByID ")
- If Not (Rs. eof Or Rs. bof) Then
- HasR=False
- Else
- HasR=True
- End If
- Rs. Close
- SetRs=Nothing
- HasRHasReCordById= HasR
- End FunCtion
-
- '*************************************** *******
- '* Obtain the record set using SQL language Rule Statements
- '*************************************** *******
- FunCtion GetRsBySql (SQL)
- Call CheCkSql (SQL, "R ")
- Dim Rs
- SetRs=Server. CreateObjeCt ("Adodb. ReCordSet ")
- Rs. Open SQL, ConnEx, 1, 1
- SetGetRsBySql= Rs
- End FunCtion
-
- '*************************************** ******
- '* Get the value of a field
- '*************************************** ******
- FunCtion GetValueBySql (SQL)
- Call CheCkSql (SQL, "R ")
- Dim Rs, ReturnValue
- SetRs=ConnEx. ExeCute (SQL)
- CatChError ("GetValueBySql ")
- If Not (Rs. Eof Or Rs. Bof) Then
- ReturnValue=Rs(0)
- Else
- ReturnValue="No records"
- End If
- Rs. Close
- SetRs=Nothing
- GetValueBySql=ReturnValue
- End FunCtion
-
- '============================== Update,Insert================================
-
- '*************************************** ******
- '* Use SQL language rules to modify Data
- '*************************************** ******
- FunCtion UpdateBySql (SQL)
- Call CheCkSql (SQL, "w ")
- ConnEx. ExeCute (SQL)
- CatChError ("UpdateBySql ")
- UpdateBySql=True
- End FunCtion
-
- '*************************************** *****
- '* Insert Data using SQL language Rule Statements
- '*************************************** *****
- FunCtion InsertBySql (SQL)
- Call CheCkSql (SQL, "w ")
- ConnEx. ExeCute (SQL)
- CatChError ("InsertBySql ")
- InsertBySql=True
- End FunCtion
-
- '================================Delete==================================
-
- '*************************************** *****
- '* Use SQL statements to delete rules
- '*************************************** *****
- FunCtion DeleteBySql (SQL)
- Call CheCkSql (SQL, "D ")
- ConnEx. ExeCute (SQL)
- CatChError ("DeleteBySql ")
- DeleteBySql=True
- End FunCtion
-
- '*************************************** *****
- '* Check the SQL language Rule statement permissions, and check the statements based on the Flag.
- '*************************************** *****
- Sub CheCkSql (SQL, Flag)
- Dim StrSql, SinCounts, DouCounts, I
- StrSql=LCase(SQL)
- SinCounts=0
- DouCounts=0
- ForI=1To Len (StrSql)
- If Mid (StrSql, I, 1) = "'" ThenSinCountsSinCounts= SinCounts + 1
- If Mid (StrSql, I, 1) = "ThenDouconfulfill=DouCounts+ 1
- Next
-
- If (SinCounts Mod 2)<>0 Or (DouCounts Mod 2)<>0 Or Instr (StrSql ,";")>0 Then
- Call Class_Terminate ()
- Response. Write ("SQL language Rule error! ")
- Response. End ()
- End If
- SeleCt Case Flag
- Case "R", "r ":
- If Instr (StrSql, "delete ")>0 Or Instr (StrSql, "update") Or Instr (StrSql, "drop ")>0 Or Instr (StrSql, "insert ")>0 Then
- Class_Terminate ()
- Response. Write ("You are not authorized to run the Write operation ")
- Response. End ()
- End If
- Case "W", "w ":
- If Instr (StrSql, "delete ")>0 Or Instr (StrSql, "drop ")>0 Or Instr (StrSql, "seleCt ")>0 Then
- Class_Terminate ()
- Response. Write ("You are not authorized to run the delete operation ")
- Response. End ()
- End If
- Case "D", "d ":
- Case Else:
- Response. Write ("The CheCkSql flag is incorrect! ")
- End SeleCt
- End Sub
-
- Sub Class_Terminate
- If Not IsEmpty (FriendConn) Then
- FriendConn. Close
- SetFriendConn=Nothing
- CatChError ()
- End If
- End Sub
- End Class
- %>
We will introduce ASP Programming Using JSP programming.
- Methods for constructing JSP and Javabean development and release Environments
- Analysis of JSP Design Mode
- What is JSP and its strong weakness?
- How Tomcat improves performance on JSP pages
- Use of scripts Based on JSP tutorials