What Servlet that?
Java Servlet is a program running on the Web server or application server, which is used as an intermediate layer on the database or application server and HTTP requests from a Web browser or other HTTP client between.
Use Servlet, you can collect user input from web forms, showing records from a database or other source, you can also create dynamic web pages.
Java Servlet and under normal circumstances the use of CGI (Common Gateway Interface, Common Gateway Interface) programs can be implemented to achieve similar results. But compared to CGI, Servlet has the following advantages:
- Significantly better performance.
- Servlet performed within the Web server's address space. So that it is not necessary to create a separate process to handle each client request.
- Servlet is a platform-independent, because they are written in Java.
- Java Security Manager on the server to perform a series of restrictions to protect the resources on the server computer. Thus, Servlet is credible.
- All features of the Java class libraries are available for Servlet it. It can interact through sockets and RMI mechanism and applets, database or other software.
The following figure shows the location of the Web Servlet application.
Servlet performs the following major tasks:
- Reads the client (browser) explicit data transmission. This form includes an HTML form on the page, or may be derived from applet or a custom HTTP client program.
- Reads the client (browser) sends an implicit HTTP request data. This includes cookies, media types and browsers can understand compressed format, and so on.
- Process the data and produce results. This process may need to access the database, perform the RMI or CORBA calls, call the Web service, or directly calculated the corresponding response.
- Send explicit data (ie documents) to the client (browser). The format of the document can be varied, including text files (HTML or XML), binary files (GIF image), Excel and so on.
- Send implicit HTTP response to the client (browser). This includes tells the browser or other client document types (such as HTML) to be returned, set cookies and cache parameters, and other similar tasks.
Java Servlet is running on the web server with support for Java Servlet specification interpreter Java class.
Servlet can usejavax.servlet and javax.servlet.httppackage creation, it is a standard part of the Java Enterprise Edition, Java Enterprise Edition supports large-scale development projects extended version of the Java class libraries.
These classes implement Java Servlet and JSP specifications. In writing this tutorial, when both the corresponding versions are Java Servlet 2.5 and JSP 2.1.
Java Servlet just like any other Java class has already been created and compiled. After you install the Servlet package and add them to the classpath Classpath on your computer, you'll be able to compile the Servlet by JDK Java compiler or any other compiler.
The next step?
Next, the tutorial will take you step by step to set up your Servlet environment, in order to start subsequent Servlet use. Therefore, please fasten your seat belts, we together with the start Servlet learning journey! I believe you will like this tutorial.