JSP: Introduction to JSP and Servlet

Source: Internet
Author: User

JSP entry: What is jsp?

JSP (Java Server Pages) is a dynamic web page technical standard proposed by Sun Microsystems and jointly established by many companies. Insert the Java program segment (Scriptlet) and JSP tag in the traditional webpage HTML file (*. htm, *. html) to form a JSP file (*. jsp ).

To put it simply, jsp is an html file that may contain a java program segment. to distinguish it from a common html file, the jsp suffix is used. Many jsp tutorials always start with jsp and asp, but many jsp beginners do not know what asp is. Is it interesting?

The following figure shows a common HTML request process:

Because JSP contains java program code segments, JSP requires more processing steps in the web server. As shown in:

You will find that there is an additional JSP iner, and then a process of converting to a java file named xxxServlet and compiling it into a class file. The core part of the java Server-Servlet is shown here.

JSP entry: What is Servlet?

Servlet is a server-side Java application independent of platform and protocol. It can generate dynamic Web pages. It serves as the intermediate layer between the request sent by a Web browser or other HTTP client programs and databases or applications on the HTTP server.

Servlet is a Java application on the server inside the Web server. Unlike the traditional Java application started from the command line, Servlet is loaded by the Web server, the Web server must contain a Java virtual machine that supports Servlet.

On servers with a large amount of communication, Java servlet has the advantage of faster execution speed than CGI programs. Each user request is activated into a thread in a single program, and a separate program is created, which means that the system overhead of each request is relatively small.

In short, servlet is a java program executed on the server. It can process user requests and respond to these requests. Servlet programming is purely java programming, while jsp is a moderate form of html and java programming. It is more helpful for the artist to design the interface. In this case, all jsp files will be eventually converted to java servlet for execution.

From jsp to java to class, jsp takes a certain amount of server resources for the first request. Fortunately, this happens only once. Once the jsp file is translated and compiled into the corresponding servlet, it will be processed directly by the servlet in the next request, unless the jsp has been modified.

From the comparison of the above two images, we can see that as a jsp server, there is a JSP iner more than a common web server, which is used for jsp interpretation and execution. For beginners, Tomcat is a very good choice for such application servers. Http://tomcat.apache.org/the latest tomcat downloads are listed above. We recommend that you extract the running version instead of the installed version. In fact, extracting the running version is not much more complicated than the installation version. It is enough to decompress the JAVA_HOME environment variable.

  1. Introduction to the Forward and sendRedirect methods of JSP
  2. Analysis on CGI supported by jsp http Server
  3. Use JSP pages to generate PDF reports
  4. Step for customizing JSP labels
  5. Detailed test of JSP containers

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.