Comparison between Java servlet and applet, CGI, JSP

Source: Internet
Author: User
<span id="Label3"></p><p><p>Java servlet is a server-side Java application that is independent of platform and protocol, and can generate dynamic web Pages.</p></p><p><p>Java servlet is a server-side Java application located inside a web server, Unlike a traditional Java application launched from the command line, which is loaded by a Web server that must contain a Java virtual machine that supports Servlets.</p></p><p><p>Java servlet vs. Applet comparison:</p></p><p><p>Similarities:</p></p><p><p>They are not standalone applications and do not have a main () method.</p></p><p><p>They are not called by the user or programmer, but by another application (container).</p></p><p><p>They all have a life cycle that includes the Init () and destroy () METHODS.</p></p><p><p>The Difference:</p></p><p><p>Applets have a good graphical interface (AWT), along with the browser, running on the client Side.</p></p><p><p>The Java servlet does not have a graphical interface and runs on the server Side.</p></p><p><p>Comparison of Java servlet with CGI (Common Gateway Interface):</p></p><p><p>Compared to traditional CGI and many other cgi-like technologies, Java servlets are more efficient, easier to use, more powerful, better portable, and less expensive to Invest. In the future of technology development, the servlet is likely to replace CGI completely.</p></p><p><p>Efficient</p></p><p><p>In traditional cgi, each request starts a new process, and if the CGI program itself executes a short time, the overhead required to start 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).</p></p><p><p>In traditional cgi, if there are n concurrent requests for the same CGI program, the code of the CGI program is repeatedly loaded n times in memory, whereas for a Java Servlet, the request is processed by N threads, requiring only one copy of the Servlet class Code. In terms of performance optimization, Servlets also have more options than cgi.</p></p><p><p>Convenient</p></p><p><p>Java Servlet provides a number of utility routines, such as parsing and decoding HTML form data automatically, reading and setting HTTP headers, processing cookies, tracking session state, and so On.</p></p><p><p>Powerful features</p></p><p><p>In Java servlets, Many tasks that are difficult to accomplish with traditional CGI programs can be done easily. For example, a Java servlet can interact directly with a web server, while a normal CGI program Cannot. Servlets can also share data across programs, making it easy to implement features like database connection Pooling.</p></p><p><p>Good portability</p></p><p><p>Java servlet is written in java, and the Servlet API has a well-established Standard. therefore, a servlet written for iplanet Enterprise server can be ported to apache, Microsoft iis, or WebSTAR without any substantial changes. Almost all mainstream servers support servlets either directly or through Plugins.</p></p><p><p>Save Investment</p></p><p><p>Not only are there many inexpensive and even free Web servers available for personal or small-scale web sites, but for existing servers, if it doesn't support servlets, adding this functionality is often free (or requires minimal investment).</p></p><p><p>Comparison of Java servlet and JSP (JavaServer Pages):</p></p><p><p>JavaServer Pages (jsp) is a technology that implements common static HTML and Dynamic HTML mixed coding, and JSP does not add any functionality that is inherently not possible with Servlets. however, It is more convenient to write static HTML in the JSP without having to use the PRINTLN statement to output each line of HTML Code. More importantly, with the separation of content and appearance, tasks of different natures in page authoring can easily be separated: for example, HTML design by the page designer, while leaving room for Java servlet programmers to insert dynamic Content.</p></p><p><p>Comparison between Java servlet and applet, CGI, JSP</p></p></span>

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.