- Let's talk a little about the network.
- Let's consider the structure of the client-server and three-level architecture.
- Let's look at the HTTP/HTTPS protocols.
- Let's learn everything you need to know about Maven.
- Let's talk about servlets.
- Servlet containers.
- And finally - about MVC.
Part 1. Let's talk a little about the network
Let's start with the most important thing and talk about the basis on which all social networks, web services and applications, instant messengers and simple sites are built - about the network ( in the context of this series of articles, the term “network” means the Global Internet ). A network consists of a huge number of computers: they are interconnected and capable of communicating. It's important to understand how they do this, because web applications are responsible for transferring information from one computer to another.OSI network model
The OSI (Open Systems Interconnection) model creates a layered approach to building a network. It clearly shows how and at what level members of the same network can interact with each other. In total, this model contains 7 levels:7 | Applied |
6 | Representation |
5 | Session |
4 | Transport |
3 | Network |
2 | Duct |
1 | Physical |
-
1. Physical level - here the laws of physics do their job, and the task of man is to use and direct this for his own purposes. For example, creating cables and laying them to network members.
We are not interested.
-
Data link layer - responsible for transmitting data to network nodes and creating data transmission channels on physical objects.
Нам не интересен, если только нет желания писать прошивку для каналообразующей аппаратуры.
-
Сетевой уровень — для определения addressов отдельных пользователей сети и маршрутов к ним. На этом уровне стоит остановиться подробнее, а именно — на addressе пользователя в сети.
Он определяется специальным протоколом: самый распространённый — IPv4 (Internet Protocol version 4). Именно его нужно использовать веб-программисту для обращения к другому абоненту сети.
IPv4 состоит из четырех byteовых значений, разделенных точкой, например: 192.0.2.235. Стоит помнить, что значения byteовые, а значит, они лежат в пределах 0..255.
IP-address, в свою очередь, делятся на классы, и просто так присвоить себе красивую комбинацию циферок не получится, но так сильно углубляться мы не станем. Достаточно понимать, что IP-address — это уникальный идентификатор абонента в сети, по которому мы сможем к нему обратиться.
-
Транспортный уровень — занимается доставкой информации addressту. Для этого используются разные протоколы, которые нам пока не интересны. Гораздо больше нас интересует понятие, которое появляется на этом уровне, — port.
Порты отвечают за идентификацию конкретного applications на компьютере. Например, ты написал чат на Java, установил на 2 компа и хочешь отправить своему собеседнику. Твое сообщение упаковывается, отправляется по конкретному IP-addressу, доставляется твоему собеседнику, но его ПК не знает, что делать с полученной информацией, так How не понимает, Howое приложение должно обработать твое сообщение. Для этого и указываются порты при общении абонентов в сети.
Порт представляет собой число от 0 до 65535. Он добавляется к IP-addressу после двоеточия: 192.0.2.235:8080. Но нельзя использовать все порты из указанного диапазона: часть из них зарезервирована под операционную систему, еще часть принято использовать с конкретно оговоренной целью. В преднаmeaning разных портов углубляться не будем, пока достаточно понимать их роль в процессе общения в сети.
-
Сеансовый уровень — создает и управляет сеансами связи приложений. На этом уровне становится возможным взаимодействие приложений, отправка requestов служебного уровня. Для нас важно знать, что на этом уровне между двумя абонентами открывается сессия (session), с которой нам часто придется работать.
Сессия — сущность, которая создается при установке связи между двумя пользователями. В ней можно сохранять нужную нам информацию о юзере, об истории их взаимодействия. Важной деталью является то, что при остановке обмена информацией сессия не пропадает, а сохраняет свое состояние на протяжении установленного промежутка времени, поэтому пользователи могут продолжить обмен информацией после перерыва.
If an application communicates with several users simultaneously, an appropriate number of connections, and therefore sessions, are established. Each session has a unique identifier (ID) , which allows the application to distinguish between the users with whom communication occurs.
-
Presentation layer - responsible for encoding/decoding data. Obviously, if we need to send the string “Hello web” to another user, it is first converted (encoded) into binary code, and only then sent. Once it reaches the destination, the message is converted back (decoded) and the recipient can see the original string. These actions occur at the presentation level.
-
The application layer is the most interesting layer for us. It allows applications to interact with the network. At this level we will receive, send messages, make requests to services and remote databases.
There are many protocols that are used at this level: POP3, FTP, SMTP, XMPP, RDP, SIP, TELNET and, of course, HTTP/HTTPS. A protocol is a universal agreement that we adhere to when composing messages. We will definitely talk about the HTTP/HTTPS protocols separately and in more detail.
- IP address—the address of the subscriber on the network;
- Port — application address of a specific subscriber;
- Session is an entity that exists throughout the entire communication between two subscribers;
- Application protocols (HTTP/HTTPS) are the rules that will guide us when composing and sending messages.