Home  >  Article  >  Web Front-end  >  Getting Started with JavaWeb for Rookies 1 (My own learning and understanding, please give me some advice from experts if I’m wrong)

Getting Started with JavaWeb for Rookies 1 (My own learning and understanding, please give me some advice from experts if I’m wrong)

WBOY
WBOYOriginal
2016-09-15 11:15:131248browse

1. Relevant basic knowledge

1. C/S (Client/Server) architecture and B/S (Browser/Server) architecture

First of all, let’s talk about the C/S architecture. To put it simply, it is very common. Applications such as QQ that require downloading clients are built on the C/S architecture. To go deeper, it is a distributed architecture. Each client directly connects to the database server, and data processing depends on the client. Therefore, we often see QQ getting stuck while using it. As a result, the following problems will arise when choosing C/S architecture during software development:

1) All clients connect to the database concurrently, which directly limits the number of client programs running at the same time.

2) It needs to be installed, which is troublesome. (However, this cannot stop the popularity of various apps now)

3) Once Party A needs to update the software, all client computers need to be updated as well. (Baidu Browser (mobile version) pops up update prompts every day, which is annoying, and there is no button to turn off updates. In fact, it is good to update QQ every once in a while. The consequence of updating too frequently is that I finally abandoned Baidu Browsing. Device (mobile version))

The second is the B/S architecture, which is an improved version of the C/S architecture. For example, many online videos no longer require client installation. As long as you have a browser, all WEB services are performed on the browser. Its connection with the database goes through a door: client-web server (door!)-database server. In this way, the number of clients connecting to the database at the same time is not limited. By the way, B/S architecture is now the preferred choice for many information management systems. I am also planning to choose this architecture for my graduation project this year. Come on, boy!

(The following are all based on B/S architecture)

2. Communication protocol

As mentioned above, the B/S architecture will go through one door: the web server (not the database server yet), then when developing applications, it will always involve the interaction between the browser and the server. The process is as follows: Client browser --Send a request to the server--The server processes the request--The server returns the response result--The client browser receives the response result (actually equivalent to clicking a link when you go online, and then the browser pops up a page you want this process). Two things are involved: URL address and HTTP protocol. More details later

3. Web resources

There are many resources in the web server that can be accessed by the outside world. According to the different rendering effects, they are divided into static resources (HTML, css, jpg, etc.) and dynamic resources (jsp, Servlet, etc.). In fact, it does not mean that static resources are motionless. Dynamic means that the accessed resources change over time. The content will change (for example, the number of train tickets will be different each time you go to see it).

(Most of the following are related to the development of dynamic resources)

4. Tomcat server

It’s still a Web server (still not a database server). In fact, there are many different types of servers (Apache, IIS servers), used for enterprises, used for teaching, etc. The difference in my opinion is the processing The capabilities of data are just different (I probably don’t know it because I’m still inexperienced at the moment). Among them, tomcat is a lightweight web server under Apache that is often used for web development and learning. It not only has the basic functions of a web server, but also provides many components such as database connection pools. (Why is there a tomcat server? If you want to develop a dynamic web page, you have to run it on major browsers to see how it goes. So how does a web page run on the Internet? It is very simple, just enter the URL and click it, that is Say you sent a request, but if you want to get the result, that is, if you want others to respond to you, you need a WEB server, and the resources you have prepared and can be responded to have been saved in it. Only then can you get Output the result of your request. After all, the result is the dynamic web page you developed)

How to install and use tomcat server, I won’t go into details here. But I can give you a rough idea of ​​what files will appear on your computer after installation.

1) bin: used to store executable files and script files of tomcat. For example, the exe file (starup.bat) that starts tomcat is placed in it. Just double-click starup.exe to start tomcat

2) conf: used to store some configuration files, such as web.xml, server.xml (there is a difference between xml and HTML language. XML language is used to describe the nature and structure of data, and HTML language is used to display data)

3) lib: used to store jar packages

4) logs: used to store tomcat log files

5) temp: temporary file

6) webapps: The main publishing directory of web applications (that is, web resources running on the web server, which are the page files you develop) is placed here. In other words, the developed web files are here. When the browser user requests At this time, it is to request the file resources here. At the same time, one thing to note is that web applications placed in the webapps directory can be directly accessed by the outside world. Simply put, if you click http://127.0.0.1:8080 (the default port number is 8080) in the address bar to enter the web page and see a cat, it means that tomcat has been successfully started, and it means that it is already in the webapps directory. Well, if you put the web page you developed in webapps, such as welcome.jsp, then if you want to open the web page you developed, you only need to enter the web page under the premise of the server to get the correct address: http://127.0.0.1: 8080/welcome.jsp So, can the address be changed? Yes, see below

7) work: working directory

5. Configure the web application virtual directory

Not satisfied with the address of a webpage you developed and want to change it? OK, configure a virtual directory (because you are not actually placing the files in this directory (still under webapps), so the directory at this time is called a virtual directory)

1) Configure the virtual directory in the server.xml file (as mentioned above, xml files are used to describe the nature and structure of data, not for display)

Open the server.xml file in Notepad format, and then add the following code:

Add The file name refers to the starting directory that appears as soon as you open the server, that is, you put The position of webapps has been taken up

Note: after saving the file, you need to restart tomcat for it to take effect

This article ends first, and we will start the next one

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn