Seven major differences between ASP and JSP

Source: Internet
Author: User

Structure of differences between ASP and JSP

In the "<%" and "%>" tags, asp uses JavaScript or VBScript scripts, while JSP is JAVA code. JSP separates the form of web pages from the code logic on the server. As a server process JSP page, it is first converted into a servlet java program running on the server ). Servlet supports HTTP requests and responses. When JSP is converted into pure JAVA code. When multiple users simultaneously request a jsp page, the app instantiation thread responds to the request. These threads are managed by WEB server processes, which are similar to ASP thread manager functions.

Differences between ASP and JSP: Performance and platform independence

Compared with C ++, VB, and other languages, JAVA is regarded as a language with low efficiency, but it sacrifices efficiency in exchange for platform independence so that JAVA can run on most operating systems without re-compilation-many are willing to pay for it. JAVA compilation code is a byte code, which is interpreted by a Java VirtualMachine (JVM) virtual machine on the operating system at runtime. Byte Code can be migrated on all platforms without any changes. Cross-platform programming tends to use the "minimum public Denominator" of all operating systems, especially when using graphical interfaces (servlets does not need any graphical interfaces ). Servlets is faster than the traditional java program applets and javaapp, because they run on the server side and there is very little need to load heavy GUIHTML guis ).

In addition, the byte code of Servlets is only executed when the customer requests it. Therefore, although it takes several seconds to load the first call to servlets, the subsequent requests are very fast, because the server has cached the running Servlets. The current JSP server has java instant compiler JIT). Therefore, JSP execution is faster than the ASP code that is interpreted and executed every time, especially when there is a loop operation in the code, JSP is faster than 1 to 2 orders of magnitude.

Differences between ASP and JSP: Session management

ASP applies the SESSION object to track the user's operation status. JSP uses an object called HttpSession to implement the same function. The Session information is stored on the server, and the Session id is stored in the cookie of the client. If the client disables cookie, the Session Id must be followed by the url. Generally, a 30-minute expiration time is set for a Session on the server. The Session will automatically expire when the customer stops the activity. The stored and retrieved information in the Session cannot be the basic data type primitivedatatypes, such as (int, double), but must be the corresponding java object (object) such as (Integer, Double ).

HttpSessionsession = request. getSession (); // get a session object or create
Session. getId () // obtain the number of sessionids
Integerid = (Integer) session. getValue ("id") // retrieves the session value and converts it to an integer session. putValue ("ItemValue", itemName); // The ItemValue must not be of the must simple type.

Differences between ASP and JSP: Application Management

Sometimes the server needs to manage parameters for the entire application so that each customer can obtain the same parameter value. Like Session, ASP uses the Application object while JSP uses the ServletContext object. The operation method is the same as Session.

GetServletContext (). setAttribute ("Item", ItemValue); // you can specify an application variable.
Integer I = (Integer) getServletContext (). getAttribute ("ItemName"); // get // item

Differences between ASP and JSP: ServerSideIncludes

ASP and JSP have similarities on server reference. Both ASP and JSP support virtual files on servers (IIS and APACHE) that support this function. However, JSP includes the results of dynamic pages, rather than the code containing the file. It is a very effective function to include files on another server without any code or objects.

ASP: <! -- # Includefile = "subfile. asp" -->
JSP: <% @ includefile = "subfile. jsp" -->

Difference between ASP and jsp java components: JavaBeans

JavaBeans is the encapsulated object data for completing predefined functions. Compared with COM and ASP, JavaBeans and JSP joins are as follows:

1. COM objects are often used to encapsulate business logic and complete High-Strength Computing for ASP pages. Reusable components make the page simple and fast, because the component consists of C ++, VB), rather than the interpreted scripting language VBScript, JScript ).

2. JavaBeans can only be developed in java. com can be developed in any language that complies with the standard object model, including Visual J ++ ). On the other hand, JavaBeans are easier to develop, because once you have mastered java, it is very easy to understand the structure of JavaBeans. Due to the complexity of com, it takes a lot of learning and training to master-even if you have c ++ and vb basics, you need additional efforts. The Com component must be registered on the server. If you modify an existing component, the server must be restarted to use it. JavaBeans do not need to be re-registered. If developers do not need to obtain full access permissions to the server, this is a huge advantage.

3. You can create a complete JavaBeans library that meets the business logic, so that non-programmers can use the library to develop dynamic websites.

4. Beans can manage database connections on the server side.

5. JavaBeans conform to the structured object model: Each Bean is composed of a constructor without parameters, and the servlet controlling it can use introspection of the province) to set its attributes. To set the built-in attributes of Bean, you must use the setProperty tag with the attribute name. If a property can be set, the Bean must have a setXxxx method, and Xxxx should be replaced by the actual property name.

Differences between ASP and JSP: JSP and database

ASP uses ODBC to connect to the database through ADO, while JAVA connects to the database through a technology called JDBC. The target database requires a JDBC driver-a database and JAVA interface, so that JAVA can access the database in a standard way. JDBC does not use server-side data sources. JAVA can access the database as long as there is a JDBC driver. If a particular database has no JDBC driver and only ODBC drivers, JAVA provides a JDBC-ODBC bridge to convert JDBC calls into ODBC calls. All JAVA compilers have a free JDBC-ODBC bridge. Theoretically, the bridge can access any common database products.

Conclusion: The JSP model is defined after ASP. It uses many advantages of ASP, such as Session and Application objects. At the same time, JSP uses a flexible and powerful JAVA language, rather than an inefficient Scripting language. ASP developers can only use Windows-based technologies, while Java and JSP are cross-platform.

  1. Get database connection in JSP
  2. JSP line feed solution
  3. Five methods for JSP page Jump
  4. Analysis of JSP page translation principles
  5. Servlet/JSP Configuration

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.