Course cainiao: Java Web Entry 1 (learn and understand yourself, please advise me more)

Source: Internet
Author: User

Course cainiao: Java Web Entry 1 (learn and understand yourself, please advise me more)

I. Basic Knowledge

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

First of all, the C/S architecture is quite common. Applications that need to download clients, such as QQ, are built on the C/S architecture. To put it deeper, it is a distributed architecture. Each client connects directly to the database server, and the data processing needs to rely on the client. Therefore, we often see that QQ is stuck when used. In this way, the following problems may occur when selecting the C/S architecture during software development:

1) All clients are connected to the database concurrently, which directly limits the number of clients running at the same time.

2) installation is required, which is troublesome. (However, this does not block the prevalence of various apps)

3) Once Party A needs to update the software, the majority of clients should also be updated together. (Baidu browser (mobile phone end) is also annoying to jump out of the update prompt every day, and there is no button to close the update. In fact, it is quite good to update QQ only once in a while, the consequence of too frequent updates is that I finally abandon the Baidu browser (mobile terminal ))

 

The second is the B/S architecture, which is a simplified version of the C/S architecture. For example, many online videos do not need to be installed on the client. As long as you have a browser, all WEB services are performed on the browser. The connection to 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 unlimited. By the way, many information management systems prefer the B/S architecture. I plan to select this architecture for this year's graduation project. Come on, young man!

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

 

2. Communication Protocol

As mentioned above, the B/S architecture will go through a web server (not a database server). When developing an application, the interaction between the browser and the server will always be involved. The process is as follows: client browser -- send a request to the server -- process the request from the server -- return the response result from the server -- the client browser receives the response result (in fact, it is equivalent to clicking a link online, then the browser jumps out of a page you want ). Two things are involved: URL address and HTTP protocol. For more information, see

 

3. Web Resources

There are many resources for external access on the Web server. Static resources (such as HTML, css, and jpg) and dynamic resources (such as jsp and Servlet) are divided based on different rendering effects. In fact, static resources are not just motionless, dynamic means that the access content will change over time (for example, the number of train tickets to be viewed each time is different ).

(The following are the development of dynamic resources)

 

4. Tomcat server

It's still a Web server (still not a database server). In fact, there are already many different types of servers (Apache and IIS servers) for enterprise and teaching purposes, in my opinion, the difference is that the ability to process data is different (it should be that I still know little about it ). Tomcat is a lightweight and commonly used web development and learning web server under Apache. It not only has the basic functions of the web server, but also provides many components such as the database connection pool. (Why is there a tomcat server? If you want to develop a dynamic web page, you must always run it on all major browsers to see how it is done. How can a Web page run on the Internet? Simply enter the URL and click it. That is to say, you have sent a request, but you need a WEB server to get the result, in addition, you have saved the resources you have prepared and can respond to people. At this time, you can get the results of your request. In other words, the result is your dynamic web page !)

 

I will not talk about how to install and use the tomcat server here. But I can probably tell you what files will appear on your computer after the installation.

1) bin: restart 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. xml is used to describe the nature and structure of data, and HTML 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: This is the main release directory of web applications (web Resources running on web servers and page files you have developed). That is to say, the developed web files are here, when a browser user requests a file resource, the file resource is requested. At the same time, you must note that the web applications stored in the webapps directory can be directly accessed by the outside world. Simply put, you can click http: // 127.0.0.1: 8080 (default port number is 8080) in the address bar to go to the webpage and see a cat, which indicates that tomcat has been started successfully, this indicates that it is already in the webapps directory. If you put the web page you developed in webapps, such as welcome. jsp. In this case, if you want to open the web page you developed, you only need to enter the web page on the premise of the server to get the correct address: http: // 127.0.0.1: 8080/welcome. can I change the address of jsp? Yes, and see the following

7) work: working directory

 

5. Configure the Web application virtual directory

I'm not satisfied with the address of a Web page you developed. Do you want to change it? OK, configure a virtual directory (because you do not actually put the file under this directory (or 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, the xml file is used to describe the nature and structure of the data, not for display)

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

<Host> Add <Context path = "/file name" docBase = "d: \ file name"/> to the file name, that is, you have occupied the webapps location.

Note: after saving the file, you must restart tomcat to make it take effect.

 

This article ends first, and then starts later.

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.