2.2. Servlet introduction

发布时间 :2023-12-11 23:00:02 UTC      

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.

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.