After Sun officially released JSP (Java Server Pages), this new Web application development technology soon attracted people's attention. JSP provides a unique development environment for creating highly dynamic Web applications. According to Sun, JSP can adapt to 85% of server products on the market, including Apache WebServer and IIS4.0.
Simple comparison between JSP and ASP
JSP is very similar to Microsoft's ASP technology. Both provide the ability to mix some program code in HTML code and explain and execute the program code by the Language engine. In an ASP or JSP environment, HTML code describes the display style of information, while program code describes the processing logic. Common HTML pages only depend on Web servers, while ASP and JSP pages require additional language engines to analyze and execute program code. The execution result of the program code is re-embedded into the HTML code and sent to the browser together. ASP and JSP are both Web server-oriented technologies, and client browsers do not require any additional software support.
ASP programming language is a script language such as VBScript, and JSP uses Java, which is the most obvious difference between the two.
In addition, there is a more essential difference between ASP and JSP: the two language engines process the program code embedded in the page in a completely different way. In ASP, the VBScript Code is interpreted and executed by the ASP engine. In JSP, the code is compiled into a Servlet and executed by the Java Virtual Machine. This compilation operation only occurs during the first request to the JSP page.
Running Environment
To execute JSP code, you must install the JSP engine on the server. Here we use Sun's assumerver Web Development Kit (JSWDK ). For ease of learning, this software package provides a large number of examples that can be modified. After JSWDK is installed, run the startserver command to start the server. In the default configuration, the server listens on port 8080 and uses http: // localhost: 8080 to open the default page.
Before running the JSP Sample Page, pay attention to the JSWDK installation directory, especially the content in the "work" subdirectory. When executing the sample page, you can see how the JSP page is converted into a Java source file and then compiled into a class file (Servlet ). The sample pages in the JSWDK package are divided into two types: JSP files, HTML files containing a form, which are processed by JSP code. Like ASP, Java code in JSP is executed on the server. Therefore, you cannot view the JSP Source Code by using the "View Source File" menu in the browser. You can only see the result HTML code. The source code of all examples is provided through a separate "examples" page.
Java Servlet is an ideal framework for developing Web applications. JSP is based on Servlet technology and has been improved in many aspects. The JSP page looks like a common HTML page, but it allows embedding and executing code. At this point, it is very similar to ASP technology. Using the cross-platform running JavaBean Component, JSP provides an excellent solution for separating processing logic and display styles. JSP will surely become a powerful competitor of ASP technology.