01-Java web

Chapter One

basic concept

web development

  • web, meaning of web page
  • static web
    • The data provided by html and css for everyone to see will never change
  • dynamic web
    • The data available to everyone is always changing, and everyone sees different information at different times and in different places.
    • Technology stack: servelet/JSP, ASP, PHP

In Java, the technology of dynamic web resource development becomes Java web

web application

web application: A program that provides browser access.

  • a.html, b.html multiple web resources, these web resources can be accessed by the outside world and provide services to the outside world.
  • Any resource that can be accessed exists on a computer in a certain corner of the world
  • URL
  • This unified web resource will be placed in the same folder, web application -> tomcat: server
  • A web application consists of multiple parts (static web and dynamic web)
    • html,css,js
    • jsp,servlet
    • java program
    • jar package
    • configuration file

After the web application is written, if you want to provide access to the outside world: you need a server for unified management;

static web

  • .htm, .html are the suffixes of web pages. If these things always exist on the server, we can read them directly

    insert image description here

  • Disadvantages of static web

    • The web page cannot be updated dynamically, all users see the same page
      • Carousel image, click special effect: pseudo-dynamic
      • JavaScript
    • He cannot interact with the database (data cannot be persisted, users cannot interact)

dynamic web

The page will be displayed dynamically: "The page display effect of the web varies from person to person"

insert image description here

shortcoming

  • If there is an error in the dynamic web resource of the server, we need to rewrite our background program. Republish
    • Shutdown for maintenance

advantage

  • Web pages can be updated dynamically, and all users do not see the same page
  • He can interact with the database (data persistence: registration, product information, user information)

insert image description here

web server

Technical explanation

ASP

  • Microsoft: ASP is the earliest popular in China
  • Embed VB script in html, ASP+COM
  • In ASP development, basically a page has thousands of lines of business code, and the page machine is chaotic
  • high maintenance cost
  • c#

PHP

  • The development speed of PHP is very fast, the function is very powerful, cross-platform, and the code is very simple
  • Situations that cannot carry a large amount of traffic (limitations)

JSP/servlet

B/S: browser and server

C/S: client and server

  • The B/S architecture promoted by sun company
  • Based on the Java language (all big companies, or some open source components, are written in Java)
  • Can bear the impact of the three high problems

web server

The server is a passive operation, used to process some requests from users and give users some corresponding information.

Tomcat

folder role

insert image description here

Start and shut down tomcat

insert image description here

configuration

insert image description here

You can configure the port number to start, and you can configure the name of the host

  • The default port number of tomcat is 8080
  • mysql:3306
  • http:80
  • https:443

insert image description here

The name of the configurable host

  • Default hostname: localhost->127.0.0.1
  • The default website storage location: webapps

insert image description here

publish a web site

Put the website you wrote on the server (tomcat) under the specified web application folder (webapps), and you can access it

website architecture

  • webapps: the web directory of the tomcat server
  • root
  • wangzhan: the directory name of the website
    • WEB_INF
      • classes:java program
      • lib: the jar package since the web application
      • web.xml: configuration file for the website
    • index.html: The default home page
    • static
      • html
      • css
      • js
      • img

http

basic introduction

HTTP (Hypertext Transfer Protocol) is a simple request-response protocol that usually runs on top of TCP.

  • text: html, string...
  • Hypertext: pictures, music, video, location, map
  • 80

https: secure

  • 443

http request

Client sends request to server

insert image description here

request line

Request method: get, post

  • get: The number of parameters that can be carried is relatively small, the size is limited, and the data content will be displayed in the URL address bar of the browser. It is not safe, but efficient
  • post: There is no limit to the parameters that can be carried in the request, and there is no limit to the size. The data content will not be displayed in the URL address bar of the browser. It is safe but not efficient.

header

insert image description here

http response

server – response – client

insert image description here

response body

insert image description here

request status code

404: Resource not found

200: The request was successful

3**: request redirection

  • Request redirection: you go back to the new location I gave you

5**: Server error (500) 502: Gateway error

maven

basic introduction

In the development of Javaweb, a large number of jar packages need to be used, and maven can help us automatically import and configure them.

main idea

convention over configuration

Guess you like

Origin blog.csdn.net/qq_52117201/article/details/129400996