After the ASP (ActiveServerPage) has been launched from Microsoft, it has been liked by its powerful function, simple and easy to learn. However, it has the common disease of Microsoft products, can only be used under the Windows platform, although it can be used under Linux by adding controls, but its most powerful DCOM control cannot be used. The JSP (Java Serverpages) developed at Java's basis achieved the separation of dynamic pages and static pages, separated from the binding of the hardware platform, and the compiled operation, etc., greatly improved its execution efficiency and gradually became an Internet. Mainstream development tool. In order to use the major to apply ASP programmers to learn JSP. It is now contrasted as follows: 1. Structure JSP and ASP are similar in structure,
"As a standard, the difference is the code ASP between the standards as JavaScript or VBScript scripts, while JSP is JAVA code. JSP is separated from the representation of the web page and the code logic of the server side. As the JSP page of the server process, First converted to servlet (a server-side Java program). Servlet supports the request and response of the HTTP protocol. When the JSP is converted into a pure Java code. When multiple users meet a JSP page, apply instantiated threads to respond Request. These threads are managed by the web server process, similar to the ASP's thread manager function. Creating a process with a CGI to create a process of a process, which is more efficient. Second, performance and platform independence with C , VB and other languages, Java is considered a language that is less efficient, but it is in exchange for the platform independence to make Java can run on most operating systems without recompilation - many people are willing to This is a cost. Java's compile code is a character code that interprets a Java VirtualMachine (JVM) virtual machine on the operating system. Byte code can be migrated on all platforms without any changes. The cross-platform programming tends to adopt all operating systems, especially when using the graphical interface (servlets does not require any graphical interface) .Servlets is fast than the traditional Java program (Applets, JavaApp), because they are in the server Running, no need to load heavy GUI (HTML GUI is very small). In addition, servlets' byte code is only performed when the customer request is requested, so although the load time of a few seconds when calling servlets for the first time. However, subsequent requests are very fast, because the server has cached running servlets. The current JSP server has a Java Instant Compiler (JIT), so the JSP execution is faster than each time you explain the executed ASP code. In particular, when there is a loop operation in the code, the speed of JSP is faster 1 to 2 quantities. 3. SESSION management To track the user's operational status, the ASP application session object. JSP uses an object called HttpSession to achieve the same functionality. The session information is saved in the server side. The session ID is saved in the cookie of the client. If the client is prohibited from cookie, the session ID must be taken behind the URL. Squsion generally sets a 30-minute expiration time on the server, when customers Automatic failure after stopping the activity. Save and retrieve information in the assness cannot be the basic data type (PrimitiveDataTypes) such as (int, double) ), Etc., but must be the corresponding Object (object) of Java, such as Integer, Double.
HttpSessionSession = Request.getSession ();
// Get a session object or create one
session.getid () // Get the number of sessionid
IntegerID = (Integer) Session.getValue ("ID")
// Retrieve the value of the session and transform into integers
Session.putValue ("ItemValue", ItemName;
// ItemValue must not be a MUST simple type
Fourth, 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 Application objects and JSP uses servletContext objects, and the method of operation and session.
GetServletContext (). SetAttribute
("Item", itemValue;
// Set an application variable
Integeri = (Integer)
GetServletContext (). GetaTtribute ("itemname");
// get // item
5. ServersideInCludes has the same thing as the ASP and JSP on server-side references. Both ASP and JSP can support this feature server (IIS, APACHE) to implement the server-side containing virtual files. But JSP is included in the result of the dynamic page instead of the code itself containing the file. When you contain the files on another server, it does not contain any code and objects is a very effective feature.
Asp:
JSP: <% @ includefile = "subfile.jsp" ->