agreement

Published 2026-07-29 10:25 Updated 2026-07-29 10:25 1253 words 7 min read ... Page views

This article introduces the basic concepts of the HTTP protocol, request and response structures, common request methods and response status codes, and emphasizes the stateless nature of HTTP and the connection reuse mechanism. It also explains that HTTPS provides confidentiality, integrity and identity authentication through TLS, pointing out that security needs to combine protocol and service-level protection; Finally, it explains in detail the steps of configuring the Maven Web project in IntelliJ IDEA and deploying it to Tomcat.

http protocol

HTTP Overview

HTTP is the abbreviation of Hypertext Transfer Protocol, and its Chinese name is “Hypertext Transfer Protocol.” It specifies the format and interaction rules for requests and responses between clients and servers.

HTTP usually runs on top of TCP. The client first sends an HTTP request to the server, and the server returns an HTTP response after processing it.

The main characteristics of HTTP

stateless

The HTTP protocol itself does not automatically remember the business status from previous requests. The server can maintain login status and business data through mechanisms such as cookies, Session, Token or database.

Request and response models

An HTTP interaction usually consists of a request and a response. HTTP/1.1 supports persistent connections by default, so it cannot be simply understood as “the TCP connection must be disconnected immediately after each request ends.” Whether a connection is reused also depends on the protocol version, request headers, server configuration, and network environment.

http request message

An HTTP request message usually consists of the following parts:

  • Request line.

  • Request header.

  • Blank line.

  • Optional request body.

request line

The request line contains the request method, request target, and HTTP version, for example:

GET /users?id=10 HTTP/1.1

The query parameters are located in the request target and are not part of the request header.

Common request methods

GET

Usually used to obtain resources. Query parameters are often written after the URL, so they easily appear in the address bar, browser history, server log, etc.

GET is not naturally more “insecure” than POST; whether it is safe depends on factors such as whether HTTPS is used, whether sensitive parameters are exposed, and server permissions verification. There is also no fixed upper limit for URL length that is uniformly stipulated by HTTP, but browsers, servers, and proxies may set their own limits.

POST

It is usually used to submit data to the server or trigger processing operations. When using method="post" for forms, form data is usually placed in the request body.

Similar to GET, but the server only returns the response header and does not return the response body. It is often used to obtain resource metadata.

PUT

It is usually used to create or replace specified resources as a whole, and is more common in REST-style interfaces.

DELETE

Usually used to delete specified resources. The server still needs to undergo identity authentication, authority check and business verification.

Common request headers

request headaction
Acceptdeclares the type of response content that the client can receive
Accept-Languagedeclares the client’s preferred language
Content-Typedeclares the data type of the request body
Cookiesends qualified cookies to the server

Common request body types

Form coding

Content-Type: application/x-www-form-urlencoded

Example of request body:

username=tom&password=123

file upload

Content-Type: multipart/form-data

This format can submit ordinary fields and file content in the same request, and the actual request header will also contain boundary used to separate various parts.

XML

Content-Type: application/xml

JSON

Content-Type: application/json

JSON uses double quotes to represent the object’s property names and string values:

{
    "username": "tom",
    "password": "123",
    "name": "tom"
}
{
    "name": "财务部",
    "id": 5001,
    "employees": [
        {
            "name": "tom",
            "age": 20
        },
        {
            "name": "jack",
            "age": 23
        }
    ]
}

HTTP response message

An HTTP response message usually consists of the following parts:

  • Status line.

  • Response head.

  • Blank line.

  • Optional response body.

Example status line:

HTTP/1.1 200 OK

HTTP status code

The status code consists of three digits, with the first digit indicating the response category.

Status CodeNameMeaning
200OKrequest was successful
400Bad RequestRequest format or parameters do not meet server requirements
401UnauthorizedValid identity authentication has not been completed
403ForbiddenThe server understands the request but refuses to execute it, a common reason being insufficient permissions
404Not FoundThe requested resource does not exist or the address is incorrect
405Method Not AllowedResource does not support the current request method
500Internal Server ErrorAn error occurred in the server’s internal processing
502Bad GatewayGateway or proxy received an invalid response from upstream server

4xx usually indicates that there is a problem with the client request, and 5xx usually indicates that there is a problem when the server is processing the request.

Common response headers

response headaction
Content-Typedeclares the data type and character encoding of the response body
Content-Lengthdeclares response body length
Locationis often used for redirection to specify a new resource address
Set-Cookierequires the browser to store cookies according to the rules

Cookies in requests use the Cookie request header, and the server uses the Set-Cookie response header when setting cookies.

HTTPS protocol

Overview of HTTPS

HTTPS can be understood as transmitting HTTP over a TLS secure channel. SSL is the historical predecessor of TLS, and relevant certificates are still often referred to as SSL Certificates in daily materials.

TLS mainly provides the following security capabilities:

  • Confidentiality: Encrypt transmitted data to reduce the risk of content being eavesdropped.

  • Integrity: Detects whether the transmission content has been tampered with.

  • Authentication: Verify the identity of the server through a digital certificate; you can also verify the identity of the client in specific scenarios.

Difference between HTTP and HTTPS

Comparison ItemsHTTPHTTPS
default port80443
transmission protectionNot encrypted by defaultUse TLS encryption and verify integrity
identity authenticationThe agreement itself does not provide certificate certificationServer identity is usually verified through a digital certificate
address prefixhttp://https://

Using HTTPS does not mean that the business system is absolutely secure. Servers still need to correctly handle identity authentication, authority control, input verification and sensitive data storage.

Configuring Tomcat in IntelliJ IDEA

The following steps apply to traditional Maven Web projects. Menu names may differ slightly in different versions of IntelliJ IDEA.

Step 1: Create the Maven Web Project

Create the Maven project and prepare the Web resource catalog and Servlet-related dependencies.

Step 2: Configure Web Facet

Open Project Structure, add or review the web configuration in Faces, and then apply the settings.

Step 3: Add Tomcat running configuration

Open Edit Configuration in the Run menu and add the Local configuration under Tomcat Server.

image-001
image-001

Step 4: Deploy the project Artifact

Add the Artifact of the current Web project to the Deployment page of Tomcat’s run configuration and check the application context path.

image-002
image-002
image-003
image-003

Step 5: Launch and access the project

Start Tomcat, verify that there are no deployment errors in the console, and then access in the browser:

http://localhost:8080/pjt0721/index.html

pjt0721 is the application context path, and index.html is the resource to be accessed. The actual address should be consistent with the deployment configuration.

If you enjoyed this, leave a comment~

... Page views
© 2026 跨越星轨的客 @Hoshiumi
Powered by theme astro-koharu · Inspired by Shoka