agreement

Published 2026-07-29 10:25 Updated 2026-10-13 17:14 1269 words 7 min read ... Page views AI-reviewed An AI proof-read this post, but it still deserves a careful read. AI-rewritten Someone else wrote the original; AI helped me rewrite and polish it.

AI-reviewed An AI proof-read this post, but it still deserves a careful read.

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 way to maintain sessions through mechanisms such as cookies. It also explains that HTTPS provides confidentiality, integrity and identity authentication through TLS, and points out that security needs to combine protocol and service-level protection. Finally, specific steps are given for configuring Tomcat to run Web projects in IntelliJ IDEA.

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 Persistent connections are supported by default, so they cannot simply be 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. form uses method="post" 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 headerrole
AcceptDeclare the type of response content that the client can receive
Accept-LanguageLanguage that declares client preferences
Content-TypeDeclare the data type of the request body
CookieSend 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 allows you to submit ordinary fields and file content in the same request, and the actual request header will also contain a boundary。

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 RequestThe request format or parameters do not meet the 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,5xx Usually indicates that there was a problem with the server processing the request.

Common response headers

response headerrole
Content-TypeDeclare the data type and character encoding of the response body
Content-LengthDeclare the response body length
LocationCommonly used for redirection, specifying a new resource address
Set-CookieRequire the browser to save cookies in accordance with the rules

Use of cookies in requests Cookie Request header, used when the server sets cookies Set-Cookie Response head.

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.

  • identity 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 itemHTTPHTTPS
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

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

Written by AI-rewritten

If you enjoyed this, leave a comment~

Loading...