1. Servlet and JSP overview _ MySQL

Source: Internet
Author: User
Tags microsoft iis
1.1assumervlet and its features Servlet is a Java technical answer to CGI Programming. Servlet programs run on the server to dynamically generate Web pages. Compared with traditional CGI and many other CGI-like technologies, JavaServlet is more efficient, easier to use, more powerful, and more portable, more cost-effective (more importantly, Servlet servlet

1.1 Java Servlet and its features

Servlet is the answer of Java technology to CGI Programming. Servlet programs run on the server to dynamically generate Web pages. Compared with traditional CGI and many other CGI-like technologies, Java Servlet is more efficient, easier to use, more powerful, and more portable, more cost-effective (more importantly, Servlet programmers earn more income than Perl programmers :-):

Efficient.

In traditional CGI, each request starts a new process. if the CGI program runs for a short period of time, the overhead required to start the process may exceed the actual execution time. In Servlet, each request is processed by a lightweight Java Thread (rather than a heavyweight operating system process ).
In traditional CGI, if there are N concurrent requests to the same CGI program, the CGI program code is repeatedly loaded N times in the memory. for Servlet, the request is processed by N threads and only one Servlet code is required. In terms of performance optimization, Servlet also has more options than CGI, such as Buffering previous computing results and maintaining database connection activities.


Convenience.

Servlet provides a large number of utility routines, such as automatically parsing and decoding HTML form data, reading and setting HTTP headers, processing cookies, and tracking session status.



Powerful functions.

In Servlet, many tasks that are difficult to accomplish by using traditional CGI programs can be easily completed. For example, a Servlet can directly interact with a Web server, but a common CGI program cannot. Servlet can also share data among various programs, making database connection pools and other functions easy to implement.


Good portability.

Servlet is compiled in Java, and the Servlet API has perfect standards. Therefore, servlets written for the I-Planet Enterprise Server can be transplanted to Apache, Microsoft IIS, or WebStar without any material changes. Almost all mainstream servers support servlets directly or through plug-ins.


Save investment.

Not only are there many low-cost or even free Web servers available for personal or small-scale websites, but if the existing server does not support Servlet, this feature is often free (or requires a very small investment ).
1.2 JSP and its features

JavaServer Pages (JSP) is a technology that implements common static HTML and dynamic HTML hybrid encoding. for details about the basic concepts of JSP, see JSP technology introduction.

Most pages generated by CGI programs are still static HTML, and dynamic content only appears in limited parts of the page. However, most CGI technologies and their variants, including Servlet, always generate the entire page through a program. JSP allows us to create these two parts separately. For example, the following is a simple JSP page:
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<HTML>
<HEAD> <TITLE> Welcome to the online store </TITLE> </HEAD>
<BODY>
<H1> Welcome </H1>
<SMALL> Welcome,
<! -- The username for the first access is "New User" -->
<% Out. println (Utils. getUserNameFromCookie (request); %>
To set account information, click
<A href = "Account-Settings.html"> here </A> </SMALL>
<P>
The rest of the page ..
</BODY> </HTML>



Below is a simple comparison between JSP and other similar or related technologies:

JSP vs Active Server Pages (ASP)

Microsoft ASP is a technology similar to JSP. JSP has two advantages over ASP. First, the dynamic part is written in Java, rather than VB Script or other Microsoft languages, which is more powerful and easy to use. Second, JSP applications can be transplanted to other operating systems and non-Microsoft Web servers.


Comparison between JSP and Servlet

JSP does not add any functions that cannot be implemented by Servlet in essence. However, it is more convenient to compile static HTML in JSP, and you do not need to use the println statement to output each line of HTML code. More importantly, with the separation of content and appearance, different types of tasks in page creation can be easily separated: for example, HTML design is performed by page design experts, at the same time, we also set aside space for Servlet programmers to insert dynamic content.

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.