Java Servlet Programming and application (i)

Source: Internet
Author: User
Tags command line comparison html form interface

  I. Overview

A servlet is a platform-and protocol-independent, server-side Java application that generates dynamic Web pages.

A servlet is a server-side Java application located inside a Web server, unlike a traditional Java application that starts from the command line, which is loaded by a Web server that must contain a Java virtual machine that supports the servlet.

Java Servlet comparison with applets:

Similarities and differences:

* They are not standalone applications and do not have the main () method.

* They are not invoked by a user or programmer, but by another application (container).

* They all have a life cycle that contains the init () and Destroy () methods.

The difference:

* Applet has a good graphical interface (AWT), with the browser, running on the client.

* The Servlet does not have a graphical interface to run on the server side.

Comparison of Java Servlet and CGI (Common Gateway Interface):

Compared to traditional CGI and many other CGI-like technologies, the Java servlet is more efficient, easier to use, more powerful, more portable, and less expensive to invest. In the course of future technology development, the servlet may completely replace the CGI.

* Efficient

In traditional CGI, each request starts a new process, and if the CGI program itself is executing for a short time, the overhead of starting the process is likely to exceed the actual execution time. In the servlet, each request is handled by a lightweight Java thread (rather than a heavyweight operating system process).

In traditional CGI, if there are n concurrent requests for the same CGI program, the CGI program's code is repeatedly loaded n times in memory, and for the servlet, the request is n threads, and only one servlet class code is required. In terms of performance tuning, the servlet also has more options than CGI.

* Convenient

The servlet provides a number of utility routines, such as automatically parsing and decoding HTML form data, reading and setting HTTP headers, processing cookies, tracking session state, and so on.



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.