The difference and connection between ASP and JSP

Source: Internet
Author: User
Tags contains include integer session id thread client
js| difference |js today on the forum looked at, there is a netizen BlueSkyAsk the question to say "ASP and JSP which is good, they have what difference?" "Forum posts please click here to see: http://www.webjx.com/bbs/topic.php?tid=4766

Dynamic Web page Technology development ASP and JSP comparison please see here: http://www.webjx.com/htmldata/2005-05-29/1117327873.html

There seems to be no thread-safety problem with the ASP, and the JSP is thread-safe. This is not to say that the ASP is good, on the contrary, ASP is not as good as JSP.

For ASP: Every request to explain the implementation of the server-side code, the implementation of the session and application in addition to the session, the other is gone, so that the ASP can not achieve static variables, do not know if there is no way to achieve, please expert advice.

In JSP, the servlet (JSP will also become a servlet) is multi-threaded, after the execution of not only session and application still, and the Servlet instance is still in memory, the request can be used directly later, it is this increase in efficiency.

I always feel that the servlet model is more advanced than ASP, and the Java language makes IT professional! This is really an ASP far can not compare.

A few differences between JSP and ASP

Session Management

In order to track the user's operation status, ASP applies the Session object. JSP uses an object called HttpSession to achieve the same function. The session information is saved on the server side, and the session ID is stored in the client's cookie. If the client prohibits the Cookie,session ID, it must be brought behind the URL. Session typically sets a 30-minute expiration time on the server, which automatically expires when the customer stops the activity. The information saved and retrieved in the session cannot be the base data type (Primitivedatatypes) such as (int, double), and must be the corresponding object (object) of Java (integer,double).

Httpsessionsession=request.getsession ()//Get a Session object or create a
Session.getid ()//Get SessionID number
Integerid= (integer) session.getvalue ("id")//retrieves the value of the session and converts it to an integral type Session.putvalue ("Itemvalue", itemname); Itemvalue must not be must simple type

Application Management

Sometimes the server needs to manage parameters for the entire application so that each customer gets the same parameter value. As with the session, ASP uses the Application object and the JSP uses the ServletContext object, the same way as the session.

Getservletcontext (). setattribute ("Item", itemvalue);//set an application variable
Integeri= (Integer) Getservletcontext (). getattribute ("ItemName");/Get//item

Serversideincludes

ASP and JSP have the same place on the server side references. ASP and JSP can support this functionality on the server (Iis,apache) to implement server-side contains virtual files. But the JSP is to include the result of the dynamic page, not the code itself that contains the file. When you include files on another server, it is a very effective function to not include any code and objects.

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



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.