JavaRush /Java Blog /Random EN /Part 1. What you need to know before learning Spring and ...

Part 1. What you need to know before learning Spring and JavaEE

Published in the Random EN group
If you have already completed studying Java SE or are close to it, it’s time to think about the next steps in conquering the profession of a Java developer. Part 1. What you need to know before learning Spring and JavaEE - 1On the one hand, you already have a good understanding of Java: you know how to work with the IDE, write programs, and much more. But what should we do next with them, the programs? How to make them cooler and “release them into the world”? It becomes obvious that it’s time to start studying Enterprise technologies. And this is where the fun begins. It doesn't matter which technology stack you decide to start with. Whether it's JavaEE or Spring, you'll probably come across a lot of things that are still beyond your understanding. Between the basics of Java and advanced technologies, there is still an intermediate level of knowledge that will help you not lose the remnants of self-control and self-confidence when reading voluminous documentation. Therefore, the purpose of this series of articles is to give you the minimum necessary theoretical knowledge for further study of JavaEE or Spring. All material is divided into 7 parts:
  1. Let's talk a little about the network.
  2. Let's consider the structure of the client-server and three-level architecture.
  3. Let's look at the HTTP/HTTPS protocols.
  4. Let's learn everything you need to know about Maven.
  5. Let's talk about servlets.
  6. Servlet containers.
  7. 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
Breaking down into abstraction layers allows specialists who work, for example, on the transport layer, not to think about the details of the network implementation at the network and session layers. This approach is also used in programming. Let's look at all the layers of the OSI model and find out which of them are interesting to us:
  1. 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.

  2. Data link layer - responsible for transmitting data to network nodes and creating data transmission channels on physical objects.

    Нам не интересен, если только нет желания писать прошивку для каналообразующей аппаратуры.

  3. Сетевой уровень — для определения addressов отдельных пользователей сети и маршрутов к ним. На этом уровне стоит остановиться подробнее, а именно — на addressе пользователя в сети.

    Он определяется специальным протоколом: самый распространённый — IPv4 (Internet Protocol version 4). Именно его нужно использовать веб-программисту для обращения к другому абоненту сети.

    IPv4 состоит из четырех byteовых значений, разделенных точкой, например: 192.0.2.235. Стоит помнить, что значения byteовые, а значит, они лежат в пределах 0..255.

    IP-address, в свою очередь, делятся на классы, и просто так присвоить себе красивую комбинацию циферок не получится, но так сильно углубляться мы не станем. Достаточно понимать, что IP-address — это уникальный идентификатор абонента в сети, по которому мы сможем к нему обратиться.

  4. Транспортный уровень — занимается доставкой информации addressту. Для этого используются разные протоколы, которые нам пока не интересны. Гораздо больше нас интересует понятие, которое появляется на этом уровне, — port.

    Порты отвечают за идентификацию конкретного applications на компьютере. Например, ты написал чат на Java, установил на 2 компа и хочешь отправить своему собеседнику. Твое сообщение упаковывается, отправляется по конкретному IP-addressу, доставляется твоему собеседнику, но его ПК не знает, что делать с полученной информацией, так How не понимает, Howое приложение должно обработать твое сообщение. Для этого и указываются порты при общении абонентов в сети.

    Порт представляет собой число от 0 до 65535. Он добавляется к IP-addressу после двоеточия: 192.0.2.235:8080. Но нельзя использовать все порты из указанного диапазона: часть из них зарезервирована под операционную систему, еще часть принято использовать с конкретно оговоренной целью. В преднаmeaning разных портов углубляться не будем, пока достаточно понимать их роль в процессе общения в сети.

  5. Сеансовый уровень — создает и управляет сеансами связи приложений. На этом уровне становится возможным взаимодействие приложений, отправка 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.

  6. 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.

  7. 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.

Part 1. What you need to know before learning Spring and JavaEE - 2 We don't need to know how each level of this model works. The main thing is to understand the principles of operation of the elements that we will have to deal with when writing web applications, namely:
  • 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.
When we go to, say, an online store, we indicate its location address and port. On your first visit, a session is created in which the store can record information. For example, about the goods that we left in the cart. If we close the online store tab and then go back to it, our products will remain in the cart because they are saved in the session. Well, of course, we receive all the information that we receive from the store via the HTTP/HTTPS protocol, and our browser can process it. You can object and say that you have never entered the address and port in the browser, and you will be partly right, because you entered the domain name, which was converted on the DNS server. But here, let’s take a better look at what’s what.

DNS (Domain Name System)

As we have already found out, each subscriber on the network has a unique address. If we are talking about an application, its unique address will be IPv4:port . Knowing this address, you can directly access the application. Let's imagine that we wrote a web application that displays the average air temperature in all countries in real time. We deployed it on a server with the address 226.69.237.119 and on port 8080. In order for the user to receive information from us, he needs to enter 5 numbers in the browser: 226.69.237.119:8080. People don't really like to remember sets of numbers: not all of us remember more than two phone numbers. That's why the domain name system was invented . We can create an “alias” for our address—for example, world-temperature.com—and instead of searching for us using a five-digit address, the user can type our domain name into the browser’s address bar. To match domain names and real addresses, there are DNS servers . When a user enters, for example, javarush.ru in the browser, his request is sent to the DNS server, where it turns into a real address. Part 1. What you need to know before learning Spring and JavaEE - 4It is important for us to understand this, because in our applications we will call remote services both by domain name and by real address, and these will be the same services. That's all! In this article, we looked at the basics of network design, which will be useful before you start learning web programming. Next time we’ll look at what client-server architecture is and why understanding it is so important. Part 2. Let's talk a little about software architecture Part 3. HTTP/HTTPS protocols Part 4. Maven basics Part 5. Servlets. Writing a simple web application Part 6. Servlet containers Part 7. Introducing the MVC (Model-View-Controller) pattern Part 8. Writing a small spring-boot application
Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION