08 JavaWeb introduction Tomcat installation and use HTTP introduction Maven novice use in IDEA


1. Basic concepts

web development

  • Static web

    • html css
    • Provide it to everyone to see that the data will never change
  • Dynamic web

    • Taobao is almost all websites

    • The data provided to everyone will change, and everyone will see different information at different times and places

    • Stack technology; Servlet/JSP ,ASP,PHP,

In Java, the development technology of dynamic web resources is collectively referred to as Javaweb

1.2 Web application

web application: a program that can provide browser access;

  • a.html b.html... Multiple web resources that can be accessed externally and provide services to the outside world
  • Any page or resource you can access exists on the computer somewhere at this time
  • URL: to access resources
  • The same web resource will be placed in the same folder, web application - > Tomcat: server
  • A web application consists of many parts (static web, dynamic web)
    • html,css,js
    • jsp,servlet
    • java program
    • jar package
    • Configuration files (Properties)

After the web application is written, if you want to provide access to the outside world, you need a server to manage it uniformly

1.3 static web

  • *. html, if these things always exist on the server, we can read them directly

  • Static web has disadvantages
    • The Web page cannot be updated dynamically. All users see the same page
    • Rotation chart, click feature: pseudo dynamic
    • JS
  • He can't protect the database, data can't be persistent, and users can't interact

1.4 dynamic Web

The page will be displayed dynamically


  • If there are errors in the dynamic Web resources of the server, we need to rewrite our background program and publish it again
    • Shutdown maintenance

2. Web server

2.1 technical introduction


  • What Microsoft did: the first popular ASP in the new year
  • Embed VB script in HTML, ASP+COM
  • In ASP development, there are thousands of lines of business code in a page, and the page is extremely chaotic
  • High maintenance cost
  • C#
  • IIS server


  • PHP development is fast, powerful, cross platform, and the code is very simple
  • Unable to carry large traffic (limitations)


B/S browser and server

C/S client and server

  • B/S architecture mainly promoted by sun company
  • Based on java language (all large companies or some open source components are written in java)
  • It can bear the impact of three high problems (high concurrency, high availability and high performance)
  • Syntax like ASP, strengthen market intensity

2.2 Web server

Server is a passive operation, which is used to process some requests of users and give users some response information


Microsoft: ASP, which comes with Wnidows


3. Tomcat

3.1 Tomca installation

3.2 Tomcat startup and configuration

Folder function

Startup and shutdown

Possible problems

  • java environment variables are not configured
  • Flash back problem: you need to select the appropriate version

3.3 configuration

The port number of startup can be configured

  • tomcat 8080
  • mysql 3306
  • http 80
  • https 443
  <Connector port="8080" protocol="HTTP/1.1"
               redirectPort="8443" />

Host name that can be configured for startup

  • The default host name is localhost - >
  • The default location of web apps is webapps
<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

Difficult interview questions

Please talk about how the website is accessed!

  1. Enter a domain name and press enter

  2. Check whether there is a mapping of this domain name under the local C:\Windows\System32\drivers\etc\hosts configuration file

    1. There is a direct return of the corresponding IP address
    2. No: go to the DNS server to find it and return it if found, and return it if not found

3.4 publish a Web site

  • Put the website written by yourself under the specified web apps folder in the server (Tomcat), and you can access it

Website structure

			-classes:java program
			-lib: web Since the application jar package
			-web.xml Site profile
		-index. html default page 


4.1 what is HTTP

HTTP hypertext transfer protocol is a simple request response write one, which usually runs on TCP

  • Text: html, string
  • Hypertext: picture, music, video, location, map

4.2 two times

  • http1.0
    • HTTP/1.0: in the early years, after the client could connect to the web server, it could only obtain one web resource and disconnect
  • http2.0
    • HTTP/1.1: after the client can connect with the web server, it can obtain multiple web resources 4.3

4.3 Http request

  • Client – request – server

Baidu as an example

Request URL: https://www.baidu.com / request address
Request Method: GET		get method /post method
Status Code: 200 OK	Status code
Remote Address:
Referrer Policy: strict-origin-when-cross-origin

Request method:

  • The parameters carried by the GET request are relatively few, and the size is limited. The data content will be displayed in the URL address bar of the browser, which is unsafe but efficient
  • There are no restrictions on the carrying parameters and size of the POST request, and the data content will not be displayed in the URL. It is safe but inefficient

4.4 Http response

  • Server – corresponding – client


2. Corresponding status code

200: request succeeded

3 * *: request redirection

4 * *: resource 404 Not Found

5 * *: server code error 500 502: gateway error

5. Maven

Why should I learn this technology

  1. In Java Web development, we need to use a large number of jar packages, which we import manually

  2. How can I make something automatically import and configure this jar package for me

    Thus Maven was born

5.1Maven project architecture management tool

At present, we are using to import jar packages.

Maven's core idea: Convention is greater than configuration

  • There are constraints. Don't break them

Maven will specify how you should write our Java code. You must follow this specification

5.2 download and install Maven

Official website: https://maven.apache.org/

5.3 environment variable configuration

In our system environment variables

to configure

  • M2_ bin directory under home Maven directory
  • MAVEN_ Directory of home maven
  • Configure% Maven in the path of the system_ HOME%\bin

5.4 Alibaba cloud image

//shift+tab format code

    <name>Alibaba cloud public warehouse</name>
    <name>central repo</name>
    <mirrorOf>apache snapshots</mirrorOf>
    <name>Aliyun Apache warehouse</name>

5.5 local warehouse

Local warehouse

Establish a local warehouse:


5.6 using Maven in IDEA

  1. Open IDEA
  2. Create a Maven project

  1. Wait until the project is automatically imported

  2. Look what's in the warehouse

  3. Maven settings in Idea need to take a look at the settings

  4. Here Maven is successfully configured and used in Idea.

5.7 create a normal Maven project

5.8 marking folder function

5.9 configuring Tomcat in IDEA

  1. Resolve warning issues,

Why is there this problem? When we visit a website, we need to specify a folder

5.10 Pom file

pom.xml is the core configuration file of Maven

<?xml version="1.0" encoding="UTF-8"?>
<!-- Maven Version and header files-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--  Here we explain what we just configured GAV-->
  <!--  package Packaging method of the project jar:java application war:javaweb application-->

  <name>javaweb-01-maven Maven Webapp</name>
  <!-- FIXME change it to the project's website -->

<!--  to configure-->
  <!--    Project default build code-->
  <!--    Compiled version-->
<!--Project dependency-->
  <!--    Specific since jar Package configuration file-->
<!--    Maven The high level of is that he will help you import this Jar Others on which the package depends jar package-->
    <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->


    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
        <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->

Maven's agreement is greater than the configuration. We may encounter the problem that the configuration file we wrote cannot be exported or take effect later. Solution:


5.11 IDEA operation

Keywords: Java Web Development Maven Tomcat

Added by baldwinw on Fri, 04 Mar 2022 13:15:22 +0200