Java Web Summary (1) -- getting started, javaweb
I. Basic Concepts 1.1. WEB development knowledge
WEB indicates the meaning of a webpage in English. It is used to indicate resources on an Internet host for external access.
Web resources on the Internet for external access are divided:
Static web Resource Development Technology: Html
Common Dynamic web Resource Development Technologies: JSP/Servlet, ASP, PHP, etc.
In Java, dynamic web Resource Development Technology is collectively referred to as Javaweb.
1.2. WEB Applications
A web application is a web application. For example, a.html extension B .html ..... Multiple web resources. These web resources are used to provide external services. In this case, you should put these web resources in a directory to form a web application (or web application)
A web application consists of multiple static and dynamic web resources, such as html, css, and js files, Jsp files, java programs, jar packages, and configuration files.
After a Web application is developed, if you want to provide external access, You need to hand over the directory where the web application is located to the web server for management. This process is called a directory-like ing.
1.3 WEB Development History
Two stages of WEB development: static and dynamic
1.4 static WEB
* Htm and * html are the suffixes of web pages. If you read the content directly on a server, it means that the content of these web pages is displayed to users through the Web server. The entire process of static WEB operations is shown as follows:
In a static WEB program, the client uses a WEB browser (IE, FireFox, and so on) to connect to the server through the Network and initiates a Request using the HTTP protocol ), tell the server which page I want to obtain and send all requests to the WEB server. Then, the WEB server extracts content from the file system (disks containing all static pages) according to the user's needs. Then, the WEB server returns the content to the client. After receiving the content, the client renders and parses the content in the browser to obtain the displayed result.
Static WEB has the following Disadvantages:
1. The content on the Web page cannot be dynamically updated. The content and final effect that all users see are the same at all times.
To make the static WEB display look better, you can add JavaScript to complete some display effects on the page. However, these effects are displayed on the client through a browser, so there is no change on the server itself.
Means to achieve the dynamic effect of the static WEB client:
JavaScript is used most in actual development.
2. The static WEB cannot connect to the database and interact with users.
Using a database to save data is now the choice of most systems, because the database can easily manage data, addition, deletion, modification, and query operations can be completed using standard SQL statements.
1.5 Dynamic WEB
The so-called dynamics do not mean page motion. The main feature is: "The WEB page display effect varies by person." Dynamic WEB is interactive, the content of the WEB page can be dynamically updated. The entire dynamic WEB operation process is shown as follows:
In dynamic WEB, the program still uses the client and server, the client still uses the browser (IE, FireFox, etc.), connects to the server through the Network, and initiates a Request using the HTTP protocol ), all requests are processed by a WEB Server plug-in. This plug-in is used to distinguish static resources (*. htm or *. htm) or dynamic resources.
If the WEB Server Plugin finds that the client requests static resources (*. htm or *. (htm), the request is directly forwarded to the WEB server, and then the WEB server extracts the content from the file system and sends it back to the client browser for parsing and execution.
If the WEB Server Plugin finds that the client requests Dynamic Resources (*. jsp ,*. asp /*. aspx ,*. php), the request is first forwarded to the WEB Container (WEB Container), connected to the database in the WEB iner, removed data from the database and a series of operations, and then dynamically pieced together the display content of the page, after splicing together the presentation content of the page, submit all the presentation content to the WEB server, and then send the content back to the client browser for parsing and execution through the WEB server.
1.6 Implementation of Dynamic WEB Applications
Currently, dynamic WEB has many implementation methods, including the following:
- Microsoft ASP and ASP. NET
- PHP
- JAVA Servlet/JSP
1. Microsoft ASP and ASP. NET
Microsoft's dynamic WEB development was relatively early, and ASP was the first and most popular in China. ASP adds the VB script to the HTML language, but the standard development application should use ASP + COM, but in actual situations, during ASP development, hundreds of codes are basically written on a single page. The page code is extremely messy.
ASP itself has development platform restrictions: Windows + IIS + SQL Server/Access, ASP can only run on Windows operating systems, ASP has basically been eliminated, and now basically all use ASP. NET development, ASP. NET has greatly improved its performance and is developed rapidly, but it is still limited by the platform. ASP. NET mainly uses the C # language.
2. PHP
PHP development is fast, powerful, cross-platform (the platform refers to the operating system running), and the Code is also simple.
3. Servlet/JSP
This is the implementation language of the B/S architecture promoted by SUN (which has been acquired by Oracle) and developed based on the JAVA language, because the JAVA language is simple enough and clean.
The performance of Servlet/JSP technology is also very high and is not limited by the platform, and can be basically used on all platforms. In addition, the multi-thread processing method is used during running, so the performance is very high.
The earliest WEB Technology launched by SUN is the Servlet program. The Servlet program itself has some problems. All the programs are written in JAVA code + HTML, that is, to use the JAVA output statement and output all the HTML code in one row and one line, SUN was inspired by ASP and developed JSP (Java Server Page ), the compiling Effect of Some JSP code is very similar to that of ASP. In this way, some ASP programmers can easily turn to JSP learning and increase competition in the market.
II. Introduction to WEB Server 2.1 and WEB Server
1. A Web Server is a program that resides on a certain type of computer on the Internet and can provide documents to the requesting browser.Program. When a Web browser (client) connects to the server and requests a file, the server processes the request and reports the file to the browser, the attached information tells the browser how to view the file (that is, the file type ).
2. The server is a passive program: the server responds only when a browser running on other computers on the Internet sends a request.
2.2. Introduction to common Web servers 1. WebLogic is an application server produced by bea. BEA WebLogic is a Java application server used to develop, integrate, deploy, and manage large-scale distributed Web applications, network applications, and database applications. Introduce the dynamic functions of Java and the security of Java Enterprise standards into the development, integration, deployment and management of large-scale network applications. Is currently the most widely used Web server, supporting J2EE specifications, and constantly improving to adapt to new development requirements, start the interface 2, WebSphere
WebSphere Application Server is a fully functional and open Web Application Server. It is the core part of IBM's e-commerce plan and is a Java-based Application environment, it is used to establish, deploy, and manage Internet and Intranet Web applications. This entire set of products has been extended to meet the needs of Web application servers, ranging from simple to advanced to enterprise level. Startup Interface
3. Tomcat
Tomcat is the smallest WEB server that implements the java ee standard. It is a core project of the Jakarta project of the Apache Software Foundation, developed by Apache, Sun, and other companies and individuals. Because Tomcat is advanced in technology, stable in performance, and free in open source, it is favored by Java enthusiasts and recognized by some software developers. It has become a popular Web application server. Tomcat servers are generally used for Java Web development. This server supports all JSP and Servlet specifications and the startup interface.
4. IIS Microsoft's Web server product is Internet Information Services (IIS). IIS is a Web server that allows Information to be published on the public Intranet or the Internet. Ⅱ S is one of the most popular Web server products at present. Many famous websites are built on the Ⅱ S platform. IIS provides a graphical management tool called Internet Information Service Manager, which can be used to monitor, configure, and control Internet services. IIS is a Web service component, including Web server, FTP server, NNTP server, and SMTP server, which are used for Webpage Browsing, file transmission, News Service, and email sending, it makes it easy to publish information on networks (including the Internet and LAN. It provides ISAPI (Intranet Server API) as a programming interface to expand Web Server functions. It also provides an Internet Database Connector to query and update databases.
To learn about web development, you must first install a web server and then develop corresponding web resources on the web server for users to access through a browser.
3. Build a Java web Application Development Environment-Tomcat server 3.1. Q: Why do I have to install a WEB server first when learning web development?
If you create a web page on a local computer, you cannot access it. However, if you start the tomcat server and place the web page in the tomcat server, you can access it. What problems does this mean?
1,No matter what web resources you want to access by a remote computer, there must be a corresponding network communication program. When a user accesses the program, the network communication program reads web resource data, and send the data to the visitor..
2. The WEB server is such a program used to complete the communication of the underlying network. When using these servers, developers of our applications only need to pay attention to how web resources are written, rather than how resources are sent to the client, which greatly reduces the development workload of developers.
3.2 download and install the Tomcat server
Tomcat official site: http://jakarta.apache.org
Download Tomcat installation package: http://tomcat.apache.org/
Click Download To Go To The Download page, as shown in.
After the download is complete, a compressed package is obtained. Unzip the package to complete the installation of the Tomcat server.
After unzipping the package, the folder shown in is obtained, which completes the installation of the Tomcat server.
3.3 start and test the Tomcat server
Start Tomcat server
Double-click the startup. bat file in the bin directory to start the Tomcat server.
Test Tomcat server
Open the browser and enter http: // localhost: 8080/. The following page is displayed, indicating that the installation is successful.
3.4 Tomcat startup FAQs
The Tomcat server cannot be started normally because of the following two reasons:
1. JAVA_HOME environment variable settings
Double-click startup in the bin directory. when the bat file starts the Tomcat server, the first thing to do is to set the JAVA_HOME environment variable in windows, because the JAVA_HOME environment variable is required for Tomcat server startup. If the JAVA_HOME environment variable does not exist in windows, the Tomcat server cannot be started.
Configure JAVA_HOME variable in Window
Operation Procedure (win7 system): Computer → right-click "properties" → advanced system settings → advanced → environment variables, as shown in:
Click "[New", A new system variable dialog box is displayed. First, write JAVA_HOME in the variable name. As the name suggests, JAVA_HOME indicates the JDK installation path, and then write the JDK installation path in the variable value, for example, the variable value is"D: \ Program Files (x86) \ Java \ jdk1.7.0", After setting the variable value, click OK. The JAVA_HOME environment variable is set, as shown in figure: A" JAVA_HOME "variable is added to the system variable.
Normally, the first step to learning Java Development is to configure the Path environment variable. A better configuration method is to configure the JAVA_HOME environment variable first and then use it in the Path variable"% JAVA_HOME %"Reference the value of the JAVA_HOME variable.
Therefore, this JAVA_HOME environment variable is usually configured in the Window. If you forget to configure the JAVA_HOME environment variable, you can use the above configuration method.
2. Port occupation Problems
The Tomcat server needs to use port 8080 by default during startup. If port 8080 is occupied by other applications, the Tomcat server cannot be started normally, as shown in: "The Tomcat server startup interface prints An Exception error message and closes it automatically:
Since the window is very short from startup to shutdown, it is difficult for us to see the error message during Tomcat startup through this window, therefore, we can only view the running status of the Tomcat server through the logs recorded by the Tomcat server.
There is a logs folder under the root directory of the Tomcat server,
The logs folder stores Tomcat log files. Open the logs folder and you can see the log files in it"Catalina. yyyy-MM-dd.log"Named log files, such as" catalina.2014-05-17.log ", are used to record the running status of the Tomcat server on February 17.
Open the catalina.2014-05-17.log file and check the log records,
The log clearly records the running status of the Tomcat server. If the Tomcat server cannot be started normally because port 8080 is occupied, the exception information shown in is recorded. by viewing the exception information, we can see why the Tomcat server cannot be started normally!
Summary: When the Tomcat server cannot be started normally, first check whether the JAVA_HOME environment variable is configured, and then check whether the port at Tomcat server startup is occupied by other applications.