Servlet study notes 1-JavaWeb architecture and server

The role of the interface

  • After the project has an interface, there will be layers, and multiple layers can be developed at the same time, so that the development efficiency of the project can be improved. (The caller does not need to care about the implementer, and the implementer does not need to care about the caller)

  • The interface divides the program into the caller and the implementer. The caller and the implementer are decoupled. Interface-oriented programming makes the project pluggable, pluggable, and has strong scalability.

Detailed B/S architecture and comparison with C/S architecture

Zero, definition

B/S structure ( Browser / Server , browser/server mode) is a network structure mode after the rise of WEB. WEB browser is the main application software of the client. This mode unifies the client, concentrates the core part of the system's function realization on the server, and simplifies the development, maintenance and use of the system. Just install on a client browser (Browser), such as Internet Explorer, server installation Oracle, Sybase, Informix or SQL Server and other databases . The browser interacts with the database through the Web Server . This greatly simplifies the client computer load, reduces the cost and workload of system maintenance and upgrades, and reduces the user's total cost (TCO).

Insert picture description here

1. Advantages

The biggest advantage of the B/S structure is that it can be operated anywhere without installing any special software. As long as there is a computer with Internet access, it can be used, and the client has zero maintenance. The scalability of the system is very easy, as long as you can access the Internet, and then the system administrator assigns a user name and password, you can use it. You can even apply online. After passing the company's internal security certification (such as CA**** certificate ), without human participation, the system can automatically assign an account to the user to enter the system.

2. Disadvantages

The B/S architecture is weaker than the CS architecture in terms of graphics performance and operating speed. There is also a fatal weakness that is restricted by the operating environment of the program. Because the B/S architecture depends on the browser, and there are many versions of the browser, the core architecture of many browsers is also very different, which has a great impact on the compatibility of the webpage, especially in the aspects of CSS layout, JAVASCRIPT script execution, etc. have a great impact.

Three, maintenance and upgrade

Improvements and upgrades of software systems are more and more frequent, and B/S architecture products clearly reflect more convenient features. For a slightly larger unit, if the system administrator needs to run back and forth between hundreds or even thousands of computers, the efficiency and workload are conceivable, but the B/S architecture software only needs to manage the server. Anyway, all clients are just browsers and do not need to do any maintenance at all. No matter how large the user is, how many branches there will not increase the workload of any maintenance and upgrade. All operations only need to be performed on the server; if it is a remote location, only the server needs to be connected to the private network to achieve remote maintenance and upgrade. And share. Therefore, the client is getting "thin" and the server is getting "fat" is the mainstream direction of the development of informatization in the future. In the future, software upgrades and maintenance will become easier and easier to use, which will save users manpower, material resources, time, and costs, which is obvious and amazing. Therefore, the way to maintain and upgrade the revolution is "thin" clients and "fat" servers.

Four, cost and choice

Everyone knows that windows almost dominates the world on desktop computers, and the browser has become a standard configuration. But in the server operating system, windows is not in absolute dominance. The software trend is that all application management software that uses the B/S architecture only needs to be installed on the Linux server with high security. Therefore, there are many choices of server operating systems. No matter which operating system you choose, most people can use windows as a desktop operating system. The computer is not affected. This has led to the rapid development of the most popular free Linux operating system. In addition to operating Linux In addition to the system is free, even the database is free, this option is very popular.

Five, heavy load

Since the B/S architecture management software is only installed on the server (Server), network managers only need to manage the server. The main transaction logic of the user interface is completely implemented on the server (Server) through the WWW browser, with very few transaction logics. In the front-end (Browser) implementation, all clients only have browsers, and network managers only need to do hardware maintenance. However, the application server runs a heavy load of data, and once the server "crash" and other problems occur, the consequences will be disastrous. Therefore, many organizations have database storage servers just in case.

Six, C/S features

C/S is also called Client/Server or Client/Server model. The server usually uses a high-performance PC, workstation or minicomputer, and uses a large database system, such as Oracle, Sybase, Informix or SQL Server. The client needs to install dedicated client software. The advantage of C/S is that it can give full play to the processing capabilities of the client PC, and a lot of work can be submitted to the server after being processed by the client. The corresponding advantage is that the client responds quickly. The main disadvantages are as follows: The client needs to install dedicated client software. Firstly, it involves the workload of installation, and secondly, any computer problems, such as viruses or hardware damage, need to be installed or maintained. Especially in the case of many branches or specialty stores, it is not a problem of workload, but a problem of distance. In addition, when the system software is upgraded, each client needs to be reinstalled, and its maintenance and upgrade costs are very high. There are generally restrictions on the client's operating system. It may be adapted to Win98, but cannot be used in Win2000 or Windows XP. Or not applicable to Microsoft's new operating system, etc., let alone Linux, Unix, etc. Client/Server is based on the local area network. Browser/Server is built on the basis of WAN.

i. The hardware environment is different: C/S is generally established on a dedicated network, in a small network environment, and the local area network provides connection and data exchange services through a dedicated server. B/S is built on the WAN and does not need to be a dedicated network hardware environment. For example, Internet access by telephone, equipment rental, and information management have a stronger range of adaptation than C/S, generally as long as there is an operating system and a browser.

​ ii. Different security requirements: C/S is generally oriented to a relatively fixed user group and has a strong ability to control information security . Generally, the highly confidential information system adopts the C/S structure and can be published through B/S. information. B/S is built on the wide area network , has relatively weak control over security, and faces an unknowable user group.

​ iii. The program structure is different: C/S programs can pay more attention to the process, can check the permissions at multiple levels, and can less consider the speed of the system. B/S's multiple considerations of security and access speed are based on the need for more optimization, which has higher requirements than C/S. The program architecture of B/S structure is the development trend, from MS's .Net series of BizTalk 2000 Exchange 2000, etc., it fully supports the system built by network components . The JavaBean component technology promoted by SUN and IBM has made B/S more mature.

Different: C/S program can be considered inevitable as a whole, and the reusability of components is not as good as the reusability of components under the requirements of B/S. The multiple structure of B/S pairs requires relatively independent functions of components and can be reused relatively well.

	iiii.系统维护不同:系统维护在是软件生存周期中,开销大。重要C/S 程序由于整体性,,必须整体考察, 处理出现的问题以及系统升级。升级难,可能是再做一个全新的系统。B/S程序由构件组成,方便构件个别的更换,实现系统的无缝升级,系统维护开销减到最小,用户从网上自己下载安装就可以实现升级。

	iiii.处理问题不同:C/S 程序可以处理用户面固定,并且在相同区域,,安全要求高需求,与[操作系统](http://baike.baidu.com/view/880.htm)相关,应该都是相同的系统。B/S 建立在[广域网](http://baike.baidu.com/view/21956.htm)上,面向不同的用户群,分散地域,这是C/S无法作到的,与[操作系统](http://baike.baidu.com/view/880.htm)平台关系最小。

1. Technology comparison

C/S structure software (that is, client/ server mode) is divided into two layers: client and server. The client is not an input and output device without computing power, but has certain data processing and data storage capabilities. The calculation and data of the application software are reasonably distributed between the client and the server, which can effectively reduce the amount of network communication and server computing. Due to the limitation of the number of server connections and the amount of data communication, the software of this structure is suitable for use in a local area network with a small number of users. Most of the current domestic ERP (financial) software products belong to this type of structure.

B/S ( Browser / Server Mode) is an improvement of the C/S structure with the rise of Internet technology. Under this structure, the business logic of the software application is completely implemented on the application server , and the user performance is completely implemented on the Web server. The client only needs a browser to process business, which is a brand-new software system construction technology. This structure has become the preferred architecture of today's application software . The e-pass management series products belong to this type of structure.

a) Comparison of data security. Due to the data distribution characteristics of C/S structured software , fires, robberies, earthquakes, viruses, hackers, etc. that occur on the client side have become terrible data killers. In addition, for group-level remote software applications, C/S structured software must install multiple servers in various places , and synchronize data between multiple servers . In this way, the data security at each data point affects the data security of the entire application. Therefore, for group-level large-scale applications, the security of C/S structured software is unacceptable. For software with B/S structure , because its data is stored centrally in the database server of the headquarters , the client does not save any business data and database connection information, and there is no need for data synchronization , so these security problems naturally do not exist. .

b) Data consistency comparison. In the C/S structured software solution, for large groups operating in different places , the model of installing regional-level servers in various places and then performing data synchronization is adopted . These servers must be synchronized every day before the headquarters can get the final data. Individual databases cannot be synchronized due to local network failures. Even if they are synchronized, each server is not the data at the same point in time. The data can never be consistent and cannot be used for decision-making. For B/S structured software , its data is stored centrally, and every business receipt generated by the client is directly entered into the central database, and there is no problem of data consistency .

c) Real-time comparison of data. In group-level applications, it is impossible for the C/S structure to see the current business happenings anytime and anywhere, and all it sees are post-event data; while the B/S structure is different, it can see all the current businesses in real time, which is convenient In order to make quick decision-making and effectively avoid corporate losses.

d) Comparison of data traceability. Because the data of the B/S structure is stored centrally, the head office can be directly traced back to the original business receipts of branches (branches, stores) at all levels, that is to say, the results seen are traceable. Most C/S structured software is different. In order to reduce the amount of data communication, only uploading intermediate report data, it is impossible to find the original documents of various branches (branches, stores) at the headquarters.

e) Comparison of service response timeliness. The business process and business model of an enterprise are not static and will inevitably be adjusted continuously as the enterprise continues to develop. The software provided by the software supplier is not perfect, so it is normal to maintain and upgrade the deployed software products. C/S structure software , because its application is distributed, it needs to be installed on each node . Therefore, even a very small program defect requires a long redeployment time. When redeploying, in order to ensure the version of each program Consistency, all businesses must be suspended for updates (ie "shock updates"), and the service response time is basically intolerable. The software of the B/S structure is different. Its applications are concentrated on the headquarters server , and each application node does not have any programs. If one place is updated, all application programs are updated, which can achieve rapid service response.

f) Comparison of network application restrictions. C/S structure software is only suitable for LAN users or broadband users (above 1M); while our B/S structure software can be applied to any network structure (including 33.6K dial-up network access), especially suitable for broadband unreachable Places (for example, some branches of the Dixintong Group can use the software system normally only by using the phone to access the Internet ).

g) Comparison of storage modes. The corresponding data of the B/S structure comes from the back-end database completely , while part of the data of the C/S structure comes from temporary files stored locally, and the remaining part comes from the database, so the response time of the C/S structure will be faster.

Two, business comparison

  1.  投入成本比较。B/S结构[软件](http://baike.baidu.com/view/37.htm)一般只有初期一次性投入成本。对于集团来讲,有利于[软件](http://baike.baidu.com/view/37.htm)项目控制和避免IT黑洞,而C/S结构的软件则不同,随着应用范围的扩大,投资会连绵不绝。
    
  2.  硬件投资保护比较。在对已有硬件投资的保护方面,两种结构也是完全不同的。当应用范围扩大,系统负载上升时,C/S结构[软件](http://baike.baidu.com/view/37.htm)的一般解决方案是购买更高性能的服务器;而B/S架构则是通过增加服务器的数量来承担更大的负载。
    
  3.  未来发展趋势,是将B/S与C/S的优势完美地结合起来,就是说,该平台的应用系统既能以B/S的方式发布运行,同时又具有C/S方式的极强的可操作性。
    

3. Development prospects

C/S and B/S have their own advantages. C/S is definitely better than B/S in terms of graphics performance and running speed, but the disadvantage is that it needs to run a dedicated client , and more importantly It is not cross-platform. Programs written in C++ under windows definitely cannot run under linux . The B/S model is different. It does not require a dedicated client , as long as the browser is included with the operating system . Convenience is its advantage. Moreover, B/S is based on web page language and has nothing to do with operating systems , so cross-platform is also its advantage, and with the progress of web page language and browsers , B/S's performance in processing and running speed It will get faster and faster, and its shortcomings will become less and less. For example, the future HTML5 is already very powerful in terms of graphics rendering and audio and file processing. However, the C/S architecture also has an irreplaceable role.

Browser, WEB server, DB server

Insert picture description here

1. The above graphics vividly describe the access process of the B/S architecture program. Please find Browser, WebServer, DBServer (we call 3tier) from the above figure.
2. What is the difference between Xiao Zhang's and Xiao Wang's interviews?
Xiao Zhang: The request path entered in the browser address bar is http://202.108.251.34:8080/egov/login.html. The access principle is: the browser searches the WAN for the computer whose IP address is 202.108.251.34. After finding this computer, go to this computer to search for 8080 related services, and you will find the Tomcat server (Web Server, Web Container, Web Container). The Tomcat server is in the state of receiving user requests. After receiving the request, it will parse the request. Path, know that the resource accessed by Zhang is the login.html resource (pure static page) in the egov application (web app), the Tomcat server is responsible for searching the resource in the web container, and the Tomcat server is responsible for sending the resource in response To the browser client (Xiao Zhang). During the whole process, there is no need to execute any java program in the egov application (web app), and the web app developer (java programmer) does not need to write any java program, just write a login.html page and put it in the egov application. can.
Xiao Wang: The request path entered in the browser address bar is http://202.108.251.34:8080/oa/delete?empno=7369. The access principle is: the browser searches the WAN for the IP address 202.108.251.34. Computer (hardware server). After finding this computer, go to this computer to search for 8080 related services, and you will find the Tomcat server (Web Server, Web Container, Web container). The Tomcat server is in a state of receiving user requests. After receiving the request, analyze the request path and know that the resource accessed by Zhang is the delete resource in the oa application (web app). This delete resource is not a static HTML page, but a small java program needs to be executed to process the user's request. , Note: The user's request path/delete and the small java program must be bound to each other. This small java program then connects to the database (JDBC). The database is responsible for deleting the data with empno=7369 and returning the deletion result to the small java program. The small java program is responsible for responding to the browser client with the delete result (Xiao Wang). ).

The difference between Xiao Zhang and Xiao Wang:
The resource that Xiao Zhang visits is a static resource in the WEB server, which ends in .html. There is no need to execute a java program in the web app.
The resource that Xiao Wang visits is a dynamic resource in the WEB server, not ending with .html. At this time, the Tomcat server is required to execute a corresponding small java program for us. So there must be a small java program in the web app.
The small java program described above refers to Servlet, and Servlet (Server let) represents the small java program on the WEB server side.
3. Please analyze the products, roles, agreements, and agreement makers involved in the B/S architecture?

a) All products and roles involved in the B/S architecture:
i. Browser (IE, FireFox, Chrome, Opera, etc.)
ii. WEB server, WEB Server, WEB Container. (Tomcat, JBOSS, GlassFish, etc.)
iii. DB server (Oracle, Mysql, SqlServer, etc.)
iv. Web App developers (Servlet programmers, us)
b) All protocols, standards, and standards involved in the B/S architecture Specifications:
i. The browser and the WEB server follow the HTTP protocol. The maker of this protocol is W3C, and this protocol is a communication protocol. The HTTP protocol includes a request protocol and a response protocol. The two protocols are only in different directions. Sending data from the browser to the server is called the request protocol. Sending data from the server to the browser is called the response protocol. Here, we use the HTTP protocol. HTTP 1.1 version (the HTTP protocol will be introduced in detail later.)
ii. There are some specifications between the developers (us) of the WEB server and the web app, such as Servlet and JSP specifications. The creator of these specifications is SUN.
iii. There is a specification between the Web app developer (us) and the database server, called the JDBC specification, and the creator of this specification is SUN.

Note: Our program depends on the formulation of specifications, there are many J2EE specifications, including: JDBC, Servlet, JSP, EJB, etc.

Introduction to Apache Tomcat Web Server

Apache Software Foundation

  1. Introduction The
    Apache Software Foundation (also known as Apache Software Foundation, referred to as ASF) is a non-profit organization dedicated to supporting open source software projects. In the Apache projects and sub-projects it supports, the software products issued follow the Apache License.

  2. Apache's open source project Tomcat Server
    Tomcat is a core project of the Apache Software Foundation's Jakarta project, which is jointly developed by Apache, Sun, and some other companies and individuals. Thanks to Sun's participation and support, the latest Servlet and JSP specifications can always be reflected in Tomcat. Tomcat 5 supports the latest Servlet 2.4 and JSP 2.0 specifications. Because Tomcat has advanced technology, stable performance, and free of charge, it is loved by Java enthusiasts and recognized by some software developers, making it a popular Web application server. The latest version is 8.0
    Apache Tomcat 6.x. Based on the advantages of Tomcat 5.5.x, it has realized the support of Servlet 2.5 and JSP 2.1.
    Tomcat was originally developed by Sun’s software architect James Duncan Davidson. He later helped turn it into an open source project and contributed to the Apache Software Foundation by Sun. Since most open source projects O'Reilly will publish a related book and design its cover as a sketch of an animal, he hopes to name the project after an animal. Because he wanted this animal to take care of itself, in the end, he named it Tomcat. The cover of the book introducing Tomcat published by O'Reilly has also been designed to look like a cat. The Tomcat logo and mascot has also been designed as a cat.

Tomat 6.x server related catalog introduction

  1. CATALINA_HOME refers to the root directory of the Tomcat server installation, for example: C:\apache-tomcat-6.0.32
  2. CATALINA_HOME/bin: Stores some Tomat server related commands, for example, startup.bat is needed to start Tomcat server, shutdown.bat is needed to shut down Tomcat server. Files with the .bat suffix are called batch files, and there are a lot of commands in the batch files. To execute a batch file is to execute some related commands in batches. The files ending with .sh in this directory are used in unix and Linux operating systems. For example, execute startup.sh in the Unix operating system, and use shutdown.sh when shutting down the server. These files are called shell files, and there are batches of shell commands in these shell files.
  3. CATALINA_HOME/conf: Stores some Tomcat server-related configuration files. There is a property configuration file ending in .properties, and a configuration file ending in .xml, such as catalina.properties file, server.xml file (this file is a Tomcat server-level configuration file configured with relevant server port number and other information) , Web.xml (this file is a "web application" related template configuration file) file, tomcat-users.xml (configuration information related to the user name and password of the Tomcat server user) file.
  4. CATALINA_HOME/lib: Stores the core program of the tomcat server. All files end with .jar. This kind of file is called a jar package. A large number of .class files are stored in the jar package. The operation of the Tomcat server mainly relies on these class files. Among them, servlet-api.jar and jsp-api.jar are servlet and jsp-related specifications formulated by SUN. The specifications here are interfaces and standards. The classes in other jar packages implement these interfaces or make calls to these interfaces.
  5. CATALINA_HOME/logs: This directory stores the log information related to the Tomcat server. Due to the limited text displayed in the DOS window, we cannot view all the information in detail after the program is abnormal. At this time, we can open the related log file to view.
  6. CATALINA_HOME/temp: Temporary binder, used to store temporary files when the Tomcat server is running.
  7. CATALINA_HOME/webapps: This is a very important directory. The Tomcat server stipulates that all web applications and web sites developed by programmers must be stored in this directory, otherwise the Tomcat server cannot find and provide web services. A folder stored in the webapps directory represents a web app (web application)
    E/webapps: This is a very important directory. Tomcat server stipulates that all web applications and web sites developed by programmers must be stored in this directory. Otherwise, the Tomcat server cannot find and provide web services. A folder stored in the webapps directory represents a web app (web application)
  8. CATALINA_HOME/work: This directory stores the .java files and the corresponding .class files generated when the Tomcat server runs JSP. (This directory can be temporarily left off, wait for the JSP to look again)

Learn from powernode servlet

Guess you like

Origin blog.csdn.net/kilotwo/article/details/114155344