In many cases, you need to pass some information, from the browser to the Web server, and eventually to the daemon. Browsers can pass this informationto the Web server in two ways: the GET method and the POST method. The GET method sends encoded user information to the page request. Between the page and the encoded information? Characters are separated as follows: The GET method, which is the default way to pass information from the browser to the Web server, produces a long string that appears in the browser’s address bar. Do not use the GET method if you are passing passwords or other sensitive information to the server. The GET method has asize limit: there is a maximum of 1024 characters in the request string. This information is used Another reliable way to pass information to a daemon is the POST method. ThePOST method packages the information in the same way as the GET method, butdoesn’t the POST method treat the information as a URL? The text string after the character is sent, but the information is sent as a separate message. Messages are sent to the daemon as standard output, which you can parse and use. Servlet usage Servlet handles form data, which is automatically parsed using different methods depending on the situation: Here is a simple URL that uses the GET method to pass two values to the HelloForm program. Http://localhost:8080/TomcatTest/HelloForm?name= Rookie course & url=www.runoob.com The following is the processing of input by the Web browser And then we’re
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. 2.6.1. GET method ¶
http://www.test.com/hello?key1=value1&key2=value2
QUERY_STRING header pass, and can be passed through QUERY_STRING environment variable access, Servlet uses doGet() method to handle this type of request. 2.6.2. POST method ¶
doPost() method to handle this type of request. 2.6.3. Use Servlet to read form data ¶
getParameter() can call request.getParameter() method to get the value of the form parameter. getParameterValues() if the parameter appears more than once, the methodis called and multiple values are returned, such as a check box getParameterNames() call this method if you want to get a complete list of all the parameters in the current request. 2.6.4. An example of the GET method using URL ¶
HelloForm.java Servlet program. We will use the getParameter() method, you can easily access the passed information:package com.runoob.test;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class HelloForm
*/
@WebServlet("/HelloForm")
public class HelloForm extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public HelloForm() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// Set response content type
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String title = "Using the GET method to read form data";
// Processing Chinese
String name =new String(request.getParameter("name").getBytes("ISO-8859-1"),"UTF-8");
String docType = " \n";
out.println(docType +
"\n" +
"
\"center\">" + title + "\n" +
"
\n" +
"
web.xml create the following entries in the file:
Principles, Technologies, and Methods of Geographic Information Systems
102