Chapter 2 xml Technology

Keywords: Eclipse Tomcat server

Chapter 2: xml, http protocol, tomcat
1.XML
1.1 XML overview
1. What is xml: English Extensible MarkUp Language.

  • Extensible markup language: markup in xml is extensible.
  • xml version number 1.0, 1.1
    xml usage: it is used to store data
  • 1. As the format of data transmission between systems
  • 2. As the configuration file of the project
  • 3. Save data with structural relationship.
    For example:

punch the clock
Sand coffee

   2.XML and html Comparison of:
	    1.xml The tag of the document can be expanded at will, html The tags are predefined.
	    2.xml Case sensitive, html Case insensitive.
	    3. html It is mainly used to display data, xml Is used to save data.
	    4. html In, spaces are automatically filtered, and xml can't.
	    5. html There can be multiple root nodes in xml There's only one inside.
	 
 1.2 XML grammar
	1.XML Document declaration for:
	  Syntax:<?xml version="1.0" encoding="utf-8" standalone="yes"?>
	       Properties: version Used to represent xml Version number of
		      encoding Used to represent xml Encoding format of
		      standalone Used to represent xml Whether the document depends on external files.
	  be careful:xml The document declaration must be placed in the first row and the first column.
	  For example:
		<?xml version="1.0" encoding="utf-8"?>
		<china name="zhongguo">
			<province name="hebei">
				<city> hengshui</city>
			</province>
		</china>
	2.XML Element definition:
	  xml Documents are operated by elements (tags). Elements are composed of start tags, attributes, text and end tags.
	  For example, tags can be nested and must be nested reasonably
		 <a>
			<b>bbbb</b>
		</a>
		Incorrect wording:
		<a>
			<b>bbbb</a>
		</b>
	3.Attribute definition:
		Syntax:<province name="hebei">
		The value corresponding to the property should be""Wrap it up.
	4.notes:
	   html Notes for:<!-- html Notes for-->
	   javaScript Notes for: References java Notes for
	   xml Notes for:<!--xml Notes for-->
	 be careful:
	  1. xml Is case sensitive.
	  2. xml The tag cannot be numeric or_Begin with an underscore. such as<1a>content</1a>,<_a>content<_a>,Wrong writing
	  3. xml The tag cannot be xml perhaps XML(Case is not allowed)Wait for the beginning.
	  4. xml The tag cannot contain special symbols such as spaces, such as<a a>content</a a>,<a:b>content</a:b> Wrong writing.

1.3 DTD constraint
   1.What are constraints: in xml In the document, we can use a file to restrict xml The content specification in the document is the constraint.
     Simply put: constraints are regulations xml What can and cannot be written in the file.
     Why are there constraints?
     because xml The file can be written at will. If the tag is written at will, it will be parsed xml The programmer doesn't know when the file is xml What does the mark in the file mean
     So use constraint specification xml Writing of documents.
   2.DTD constraint
     What is? DTD:Document type definition( DTD)Definable legal XML Document building module. It uses a series of legal elements to define the structure of the document.
		DTD Can be stated in rows XML In the document, it can also be used as an external reference.
     Syntax:<!DOCTYPE Root element name [dtd Specific constraints]>
     For example:
	  <!ELEMENT bookshelf (book+)>
	  <!ELEMENT book     (title,author,Price)>
	  <!ELEMENT title    (#PCDATA)>
	  <!ELEMENT author    (#PCDATA)>
	  <!ELEMENT Price    (#PCDATA)>
   3.DTD introduce:
    1.Directly in xml File, import dtd constraint
      Syntax:
      <!DOCTYPE bookshelf [
	  <!ELEMENT bookshelf (book+)>
	  <!ELEMENT book     (title,author,Price)>
	  <!ELEMENT title    (#PCDATA)>
	  <!ELEMENT author    (#PCDATA)>
	  <!ELEMENT Price    (#PCDATA)>
	]>
    2.External introduction method:
	>>> Local import:
	    Syntax:<!DOCTYPE bookshelf SYSTEM "book.dtd">
	>>> Public network introduction:
		<!DOCTYPE bookshelf  PUBLIC "DTD name" "DTD Files on the public network url">
  4.DTD Syntax:
	1.Element definition:
	 Basic grammar <!ELEMENT Element name element content>
	 Type corresponding to element content:
	 >>>Plain text:#PCDATA
	 >>>Child element: for example: (child element 1, child element 2,---)
	 >>>EMPTY:for instance <book />
	 >>>ANY:Represents any content. The element content can be ordinary text or child elements.
	 be careful:
	  * Represents 0 or more
	  + Represents one or more
	  | Choose one
	  ,Indicates that the child elements are arranged in order
	  ? Indicates that 0 or 1 can appear

	2.Attribute definition
	Syntax:<!ATTLIST Element name attribute name attribute type default>
	Attribute type:
		CDATA: The attribute value is any text data;
			CDATA,Namely Character Data(Character data). Indicates that the property type is character type!
		Enumerated: The attribute value must be one of the enumeration lists;
			Enumerated It is not a keyword. The enumeration list is required to define the attribute of enumeration type. When the attribute value is of enumeration type, the value of this attribute must be a value in the enumeration list
		ID: The attribute value must be unique and cannot start with a number;
			  There can be at most one element ID Properties, ID Property is used to represent the unique identifier of the element. ID Attribute is equivalent to the ID number of the element, and must be the only identification.
		IDREF: Property value must be ID The value of the attribute;
			IDREF Attribute is used to establish association with other elements, IDREF The value of the attribute must be the value of another element ID Attribute value
	Setting description of attribute type:
		#REQUIRED: indicates that the attribute is REQUIRED;


2.HTTP protocol:
1.1 HTTP overview:
1.HTTP simple
What is http protocol: it regulates the rules of interaction or communication between browser and server.
https: implemented based on http, it is more secure than http and provides authentication and communication content encryption.
The server has two levels:

Hardware: computers with relatively high configuration.
Software: it is an application, such as the mysql database server used earlier
2.Http 1.0 and Http 1.1
Difference: http1.0 communication base system. Each time a request is sent from the browser to the server, a new TCP connection needs to be established.
http1.1 establishes a Tcp connection, which can send multiple requests. After the server makes multiple responses, it finally closes the Tcp connection.
3.Http message:
http is based on request and response.
Http message:

Request information:
Request header information:
Accept text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Encoding gzip, deflate
Accept-Language zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
Connection keep-alive
Host localhost:8080
Referer http://localhost:8080/aa/regDemo.html
User-Agent Mozilla/5.0 (Windows NT 6.2; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0

3.TOMCAT server
1.1 introduction to Tomcat
The servers commonly used in web application development are those:

  • Tomcat: it belongs to apache open source organization and is free.
  • weblogic: it belongs to bea company. It is a large server and charges.
  • websphere: it's IBM, a large server, charging.
    1.Tomcat installation and uninstallation
    1.tomcat can be installed in two cases:

Download from the Apache official website: http://tomcat.apache.org Download the corresponding version, which is currently the highest version 9.0
However, it is not used in development because the high version is unstable.

Use the green version (installation free): you can use it by directly decompressing the compressed package of tomcat.
2. Start and shut down the tomcat server

Start: find the bin directory, startup.bat
Test installation succeeded: http://localhost:8080/ Go to the tomcat server and the kitten page appears, which means the installation is successful.

Close: find the bin directory, shutdown.bat
2.tomcat directory structure:

bin: it stores tomcat executable scripts and files
conf: the configuration file of tomcat is stored
For example, modify the access port number, find the server.xml file and modify it.

Note: port 80 is the default port of http protocol. When accessing web resources, port 80 can be omitted.

lib: the jar package that tomcat and web programs depend on when they are stored
logs: stores the log files of tomcat production
temp: it stores the temporary files produced by tomcat
webapps: Web Applications (web projects) are stored
work: stored servlet files produced by jsp (not now)
1.2 Tomcat diagnostics
Two common problems in tomcat startup:

There will be a flash phenomenon when starting tomcat: usually, the environment variable JAVA_HOME is not configured in the system
Or the name of this environment variable, JAVA_HOME is wrong.
Solution: configure Java in the system_ Home environment variable.

When tomcat starts, the port number is occupied: java.net.bindexception: address in ready use or Socket bind failed
Solution:

  • Modify the port number of tomcat: go to the conf directory and find the server.xml configuration file.
    For example:

  • Directly turn off the computer and restart it (the problem of tomcat starting only once can be solved.)
    Note: check the port number netstat -ano
    1.3 Web application
    What is web?
    The web is a web page, which we call the web resources of the internet host for the outside world (netizens) to access.
    web page resources are divided into two categories:

Static resources: html, css and javascript are available for users to access. The data of static web pages will not change.
Dynamic resources: Jsp, servlet,php,asp, etc. for users to access, and the data of dynamic web pages will change.
Two common architectures in web Development:

B / s: browser and server, browser and server mode, such as Taobao, JD, Amazon, etc
C / S:client and server, client and server modes, such as Xunlei download, 360 security guard, etc
difference:

  • b/s mode, advantages: you can directly access website resources without installation, which is simple and convenient. Disadvantages: sometimes access is slow.
  • c/s mode, which can be opened on the computer (mobile terminal) and used directly. Advantages: high speed. Disadvantages: when the server side is updated, the client must also be updated.

Posted by Drewser33 on Sat, 20 Nov 2021 02:38:28 -0800