Java Web series---Serverlet

Source: Internet
Author: User

Defined:

    • Servlet (Server Applet), full name Java Servlet, without Chinese translation. is a server-side program written in Java. Its main function is to interactively browse and modify data to generate dynamic Web content. The narrow-sense servlet refers to the Java language implementation of an interface, the generalized servlet refers to any implementation of the Servlet interface class, in general, people will understand the servlet as the latter.
    • A Java Servlet is a program that runs on a Web server or application server, as a middle tier between a request from a Web browser or other HTTP client and a database or application on an HTTP server.

      Using Servlets, you can collect user input from a Web page form, render records from a database or other source, and create Web pages dynamically. Java servlets typically work with programs that use CGI (Common Gateway Interface, Public Gateway interfaces) to achieve similar results. But there are several advantages to cgi,servlet compared to the following:

      • Significantly better performance.
      • The Servlet executes within the address space of the WEB server. This makes it unnecessary to create a separate process to process each client request.
      • Servlets are platform-independent because they are written in Java.
      • The Java security Manager on the server performs a series of restrictions to protect resources on the server computer. Therefore, the Servlet is trustworthy.
      • The full functionality of the Java class library is available to the Servlet. It can interact with applets, databases, or other software through the sockets and RMI mechanisms.
Servlet Schema
    • Shows the location of the Servlet in the Web application.
Servlet Tasks
    • The Servlet performs the following major tasks:
      1. Reads the explicit data sent by the client (browser). This includes the HTML form on the Web page, or it can be a form from an applet or a custom HTTP client program.
      2. Reads the implicit HTTP request data sent by the client (browser). This includes cookies, media types, and compression formats that the browser can understand.
      3. Process the data and generate the results. This process may require accessing the database, executing RMI or CORBA calls, invoking the Web service, or directly calculating the corresponding response.
      4. Sends explicit data (that is, documents) to the client (browser). The format of the document can be varied, including text files (HTML or XML), binary files (GIF images), Excel, and so on.
      5. Sends an implicit HTTP response to the client (browser). This includes telling the browser or other clients which types of documents are returned (such as HTML), setting cookies and caching parameters, and other similar tasks.
Servlet Package

A Java servlet is a Java class that runs on a Web server with an interpreter that supports the Java servlet specification.

Servlets can be created using the javax.servlet and javax.servlet.http packages, which are a standard part of Java Enterprise Edition and Java Enterprise Edition is an extended version of the Java class library that supports large-scale development projects.

These classes implement the Java Servlet and JSP specifications. In writing the tutorial, the corresponding versions are Java Servlet 2.5 and JSP 2.1, respectively.

Java Servlets have been created and compiled just like any other Java class. After you install the servlet packages and add them to the Classpath classpath on your computer, you can compile the servlet through the JDK's Java compiler or any other compiler.

 

Java Web series---Serverlet

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.