Comparison of ASP, Asp.net, JSP syntax, and built-in objects

Source: Internet
Author: User
1 helloword version 1.1 ASP

<%
Response. Write ("Hello asp ")
%>

The file name is test. asp.

1.2 Asp.net

<% @ Page Language = "C #" %>
<%
Response. Write ("Hello Asp.net ");
%>

The file name is test. aspx.

Note that Asp.net supports multi-language development, while VB.net is the default language. C # is used here, so it must be clearly controlled. Otherwise, the system will follow VB.net during compilation to report an error!

1.3 JSP

<%
Out. println ("Hello jsp ");
%>

The file name is test. jsp.

1.4 Analysis

ASP, aspx, and JSP all adopt the same embedding syntax <% code %>, and all have built-in objects for output text, Asp-response, Asp.net-response, and JSP-out.

For languages, VBScript is case-insensitive, while C # and Java are both case-sensitive;

For naming conventions, the class, attribute, and method initials of VBScript and C # Are all capitalized, while Java is used to start with a lowercase letter except for other classes.

2 basic syntax 2.1 embedded expression

(1) ASP

<% = %>

(2) Asp.net

<% = %>

(3) JSP

<% = %>

It can be seen that the three are identical.

2.2 embedded Declaration

(1) ASP

<Script language = "VBScript" runat = "Server>

Sub F
Response. Write ("Hello asp from script ")
End sub

</SCRIPT>

(2) Asp.net

<Script language = "C #" runat = "server">

Void F ()

{

Response. Write ("Asp.net from script ");

}

</SCRIPT>

(3) JSP

<%!

Public void F ()

{

Out. println ("jsp ");

}

%>

It can be seen that ASP and Asp.net use the same syntax, while JSP is different.

2.4 embedded program Fragment

(1) ASP

<% Program fragment %>

(2) Asp.net

<% Program fragment %>

(3) JSP

<% Program fragment %>

It can be seen that the three syntaxes are identical.

3 built-in object 3.1 ASP

(1) Request object

Indicates the information sent from the client to the server. It carries information such as browser information, request strings, form data, and cookies.

(2) response object

It indicates the content and operations related to the return from the server to the client. You can set the returned content, return cookie settings, and whether to cache the content.

(3) Application Object

Represents the entire application and is a variable within the scope of the application. Multiple pages are shared, so concurrent access is involved. Therefore, the lock and Unlock methods are provided for synchronization.

(4) Session Object

Indicates a session. A session has a unique ID. The client generally provides the session ID through cookies or request strings.

(5) Server Object

It represents the server environment and provides basic operations such as registering components and ing paths.

(6) objectcontext object

It is used to control ASP transaction processing and is rarely used for programming.

3.2 Asp.net

(1) Request object

The role is the same as the request in ASP.

(2) response object

The role is the same as the request in ASP.

(3) Application Object

The role is the same as the application in ASP.

(4) Session Object

The role is the same as session in ASP.

(5) Server Object

The role is the same as session in ASP.

(6) Page Object

Indicates the current page or the compiled class.

3.3 JSP

(1) Request object

The function is the same as the request in ASP and Asp.net, And the JSP file is in lower case.

(2) response object

Similar to the response in ASP and Asp.net, JSP is in lower case.

(3) Application Object

The role is the same as the application in ASP and Asp.net, And the JSP is in lower case.

(4) Session Object

The role is the same as the session in ASP and Asp.net, And the JSP is in lower case.

(5) Out object

The output to the client is similar to the response. Write () in ASP and Asp.net ().

(6) Page Object

Indicates the current page or the compiled servlet.

4. objects used for database access: 4.1 ASP

ASP uses ADO technology to access the database.

(1) connection class

Represents a connection to a database management system.

Set conn = server. Createobject ("ADODB. Connection ")

(2) command class

Execute commands on the connected database.

(3) recordset class

Record set.

Set rs = server. Createobject ("ADODB. recordset ")

(4) Field Class

(5) parameter class

(6) property class

(7) Error class

4.2 Asp.net

Asp.net uses the ado.net technology to access the database.

(1) sqlconnection

Same as connection in ASP.

(2) sqlcommand

Same as command in ASP.

(3) Dataset

Similar to the recordset in ASP.

4.3 JSP

JSP uses JDBC technology to access the database.

(1) connection class

Responsible for database connection.

(2) statemaent class

Similar to the command in ASP, it is responsible for executing SQL statements.

(3) resultset

Result set, similar to ASP recordset and Asp.net dataset.

5 conclusion

Through analysis and comparison, we can see that ASP, Asp.net, and JSP have many commonalities. They all standardize and process HTTP and SQL database processing. Their design ideas are completely consistent, but there are differences in technical implementation details.

Although their development environments and coding specifications are quite different, the design concept and processing process are extremely similar, so a project usually has only one version at the beginning, once the development is better, versions of other platforms will be released one after another. For example, discuz was first developed by PHP, and then the Asp.net version was available. If a programmer has mastered any platform, 90% of his development experience can be used on other platforms. Many programmers only need two weeks to switch between Asp.net and JSP, this is not surprising.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.