JAVA WEB1 - initial Java Web

JAVA WEB1 - initial Java Web

JavaWeb mainly refers to the general term of dynamic Web resource development technology using Java language. It is the sum of technologies to solve the related Web and Internet fields

1. Http protocol

  • HTTP protocol (HyperText Transfer Protocol) is an application layer protocol developed by W3C (World Wide Web Consortium). It is used to standardize the data format of how to communicate between browser and web server, mainly involving the request format of browser and the response format of server
  • HTTP protocol is usually hosted on TCP protocol, and the protocol hosted on TLS or SSL protocol layer is often referred to as HTTPS protocol
  • The default port number of HTTP is 80 and that of HTTPS is 443

1.1. Http request format

Request line
	The version of the path protocol requested by the request type(1.1)
Request header
	Browser related information of host request length request
 Blank line
	((one blank line)
Request body
	Also called request data, you can add any other data
POST /task01_demo01/demo1.html HTTP/1.1
Host: localhost:8088
Content-Length: 21
Cache-Control: max-age=0
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64)
name=scott&pwd=123456

1.2 Http response data

Response line
	Version of the agreement(1.0 1.1) Status code (200 Success 404 path error 500 service error) status information 
Response header
	Describes some additional information to be used by the client, including the format( key:value)
Blank line
	((one blank line)
Responder
	Text information returned by the server to the client

2,Tomcat

2.1. Download

Tomcat official website https://tomcat.apache.org/download-90.cgi

Tomcat Baidu cloud: https://pan.baidu.com/s/1iEEptTiPXPLls3wBpSUg1g Extraction code: gv2h

[external chain picture transfer failed. The source station may have anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-d2tvqrat-1626572780953)( http://m.qpic.cn/psc?/V54CA0n72MKGGb0pfLXF4OTqRY0DGvXI/ruAMsa53pVQWN7FLK88i5ppGCramJEjTYRYKirLRt8gxxq1gURFk7A6CDikIzseE5MaO4BFiZzuYECY10u2C1PTrUQ4uLxjCptvUHcM68Wo !/ b&bo=gAcGBIAHBgQDCSw!& rf=viewer_ 4)]

Unzip to the directory where you want to install

[external chain picture transfer failed. The source station may have anti-theft chain mechanism. It is recommended to save the picture and upload it directly (IMG iwziiwce-1626572780956)( http://m.qpic.cn/psc?/V54CA0n72MKGGb0pfLXF4OTqRY0DGvXI/ruAMsa53pVQWN7FLK88i5ozXp5J8ODXgQOiGzKIjkQPecqPKvaI6qInI3iYhMIBZ9qht4HOl3Z8zcmV35lMeyOMDQ6oqOCfGpLTcTYtiKjw !/ b&bo=gAc4BIAHOAQDCSw!& rf=viewer_ 4)]

Add environment variable

[external chain picture transfer failed. The source station may have anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-qz8imomj-1626572780959)( http://m.qpic.cn/psc?/V54CA0n72MKGGb0pfLXF4OTqRY0DGvXI/ruAMsa53pVQWN7FLK88i5ppGCramJEjTYRYKirLRt8goZ192BvnYdHzp.XolRm4PYQlf2k7.kHf4pbOlvVykP1HRwNtO1J89K5.cq1DRoCc !/ b&bo=gAc4BIAHOAQDCSw!& rf=viewer_ 4)]

Add CATALINA_BASE variable

CATALINA_BASE
D:\apache-tomcat-9.0.31

[external chain picture transfer failed. The source station may have anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-yv6fbsx-1626572780962)( http://m.qpic.cn/psc?/V54CA0n72MKGGb0pfLXF4OTqRY0DGvXI/ruAMsa53pVQWN7FLK88i5ppGCramJEjTYRYKirLRt8iT8dYYCyhJwe635S2 *1zXLeX0hbKl4QRilbznXdUhFg29MLEBfuP4y0bKuHf7JBrM!/ b&bo=gAc4BIAHOAQDCSw!& rf=viewer_ 4)]

Add CATALINA_HOME variable

CATALINA_HOME
D:\apache-tomcat-9.0.31

[external chain picture transfer failed. The source station may have anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-hz1ydih3-1626572780964)( http://m.qpic.cn/psc?/V54CA0n72MKGGb0pfLXF4OTqRY0DGvXI/45NBuzDIW489QBoVep5mcQmSby57ateXuhqj1ybHQX1ZEXY.EFO3zx1Z6NmD2tLox408Qrk.R9Qx *WdjhI84aohguKkDcSVuN6XlKyDH154!/ b&bo=gAc4BIAHOAQDWXw!& rf=viewer_ 4)]

Add to PATH variable

%CATALINA_HOME%\bin;%CATALINA_HOME%\lib

[external chain picture transfer failed. The source station may have anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-xflkgca6-1626572780965)( http://m.qpic.cn/psc?/V54CA0n72MKGGb0pfLXF4OTqRY0DGvXI/ruAMsa53pVQWN7FLK88i5ozXp5J8ODXgQOiGzKIjkQN6s0yCy.bzOepNd0S724RYGXeHT8BELCGVAlwK28mFKl9TA9n9rj7W2uGikbHvrmY !/ b&bo=gAc4BIAHOAQDCSw!& rf=viewer_ 4)]

2.2 unloading

Delete the directory and the variable

2.3 startup

Double click Run

[external chain picture transfer failed. The source station may have anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-o6v7ezkd-1626572780966)( http://m.qpic.cn/psc?/V54CA0n72MKGGb0pfLXF4OTqRY0DGvXI/ruAMsa53pVQWN7FLK88i5gTpZ4HiqFFoabaOcM1u8mXbnyPu7eCdM *aeig4jyysFPk4rQK1p4BHN5GLLiid5rJqGlcjup3pjAycjr9QR3Lc!/ b&bo=gAc4BIAHOAQDCSw!& rf=viewer_ 4)]

2.4 problems

2.4.1 garbled code

Open profile

apache-tomcat-9.0.31\conf\logging.properties

[external chain picture transfer failed. The source station may have anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-oy79ycdj-1626572780967)( http://m.qpic.cn/psc?/V54CA0n72MKGGb0pfLXF4OTqRY0DGvXI/45NBuzDIW489QBoVep5mcWSaX8WTGZXM0ucds5KNjRygeSEV54XWL.oaqUoNcyMo4SAqBuW8yr7A0riNBHMNHKLnLOedq3cjxCWJXOivU !/ b&bo=gAc4BIAHOAQDWXw!& rf=viewer_ 4)]

Modify configuration

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

handlers = 1catalina.org.apache.juli.AsyncFileHandler, 2localhost.org.apache.juli.AsyncFileHandler, 3manager.org.apache.juli.AsyncFileHandler, 4host-manager.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler

.handlers = 1catalina.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler

############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################

1catalina.org.apache.juli.AsyncFileHandler.level = FINE
1catalina.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.
1catalina.org.apache.juli.AsyncFileHandler.encoding = UTF-8

2localhost.org.apache.juli.AsyncFileHandler.level = FINE
2localhost.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost.
2localhost.org.apache.juli.AsyncFileHandler.encoding = UTF-8

3manager.org.apache.juli.AsyncFileHandler.level = FINE
3manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.AsyncFileHandler.prefix = manager.
3manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8

4host-manager.org.apache.juli.AsyncFileHandler.level = FINE
4host-manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
4host-manager.org.apache.juli.AsyncFileHandler.prefix = host-manager.
4host-manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8

java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter
java.util.logging.ConsoleHandler.encoding = GBK


############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.AsyncFileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.AsyncFileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.AsyncFileHandler

# For example, set the org.apache.catalina.util.LifecycleBase logger to log
# each component that extends LifecycleBase changing state:
#org.apache.catalina.util.LifecycleBase.level = FINE

# To see debug messages in TldLocationsCache, uncomment the following line:
#org.apache.jasper.compiler.TldLocationsCache.level = FINE

# To see debug messages for HTTP/2 handling, uncomment the following line:
#org.apache.coyote.http2.level = FINE

# To see debug messages for WebSocket handling, uncomment the following line:
#org.apache.tomcat.websocket.level = FINE

2.4.2 the black window flashed past

Java is not configured correctly_ Home environment variable

2.5 startup error

2.5.1 violence

Find the occupied port number, find the corresponding process, and kill the process

netstat -ano

2.5.2 gentleness: modify your own port number

Enter conf / server xml

<Connector port="8888" protocol="HTTP/1.1" onnectionTimeout="20000" redirectPort="8445" />

Generally, the default port number of tomcat is modified to 80. 80 port number is the default port number of http protocol. You don't need to enter the port number when accessing

Keywords: Java ReJava

Added by elthomo on Sun, 16 Jan 2022 17:51:18 +0200