2.2. Servlet introduction

发布时间 : 2025-10-25 13:33:39 UTC      

Page Views: 9 views

2.2.1. What is Servlet?

Java Servlet is a program that runs on a Web server or application server and acts as an intermediary between a request from a Web browser or other HTTP client and a database or application on the HTTP server.

Use Servlet can collect user input from web page forms, render records from databases or other sources, and create web pages dynamically

Java Servlet can usually achieve the same effect as a program implemented using CGI (Common Gateway Interface, Common Gateway Interface). But comparedwith CGI,Servlet, it has the following advantages:

  • The performance is obviously better.

  • Servlet is executed in the address space of the Web server. This eliminates the need to create a separate process to handle each client request.

  • Servlet are platform independent because they are written in Java.

  • The Java Security Manager on the server enforces a series of restrictions toprotect resources on the server computer. Therefore, Servlet is credible.

  • The full functionality of the Java class library is available to Servlet. Itcan interact with applets, database, or other software through sockets and RMI mechanisms.

2.2.2. Servlet architecture

The following figure shows the location of Servlet in the Web application.

Image0

2.2.3. Servlet task

Servlet performs the following main tasks:

  • Read explicit data sent by the client (browser). This includes HTML forms ona web page, or forms from applet or a custom HTTP client program.

  • Read implicit HTTP request data sent by the client (browser). This includes cookies, media types, compressed formats that browsers can understand, and so on.

  • Process the data and generate the results. This process may require accessing the database, making RMI or CORBA calls, invoking Web services, ordirectly calculating the corresponding response.

  • Send explicit data (that is, documents) to the client (browser). The document can be in a variety of formats, including text files (HTML or XML),binaries (GIF images), Excel, and so on.

  • Send an implicit HTTP response to the client (browser). This includes telling browsers or other clients what type of document is returned (such asHTML), setting cookies and cache parameters, and other similar tasks.

2.2.4. Servlet package

Java Servlet is a Java class that runs on a web server with an interpreter that supports the Java Servlet specification.

Servlet can be used javax.servlet and javax.servlet.http package creation, which is a standard part of Java Enterprise Edition, an extended version of the Java class library that supports large development projects.

These classes implement the Java Servlet and JSP specifications. At the timeof writing this tutorial, the corresponding versions are Java Servlet 2.5 and JSP 2.1.

Java Servlet, like any other Java class, has been created and compiled. After you install the Servlet packages and add them to the Classpath classpath on your computer, you can compile Servlet through JDK’s Java compiler or any other compiler.

2.2.5. What’s the next step?

Next, this tutorial will take you step by step to set up your Servlet environment so that you can start using Servlet later. So please fasten yourseat belt and start your Servlet learning journey with us. I’m sure you’ll enjoy this tutorial.

《地理信息系统原理、技术与方法》  97

最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。