Java Web Development Starter Book Example parsing (summary one) _java

Source: Internet
Author: User
Tags log log java web tomcat tomcat server websphere application server

During the period of Java Web Development, Java object-oriented Ideas and MVC development patterns can be said to be familiar. The framework I am currently working on is spring, SPRINGMVC, Hibernate. The following cloud-Habitat community Small series for everyone to organize a tutorial to help you learn javaweb related knowledge, interested friends can refer to.

I. Basic CONCEPTS

1.1, Web development related knowledge

Web, in English, the web is meant to represent a Web page, which is used to represent an Internet host's resources for external access.

Web resources for external access on the Internet are divided into:

1. Static Web resources (such as HTML pages): The data in a Web page for people to browse is always unchanged.

2. Dynamic Web resources: refers to the Web page for people to browse the data is generated by the program, at different points of time to access the Web page to see the content varies.

Static Web Resource development technology: Html

Common Dynamic Web Resources development technology: Jsp/servlet, ASP, PHP, etc.

In Java, Dynamic Web resource development technology is collectively called Javaweb.

1.2. Web Application

Web applications refers browser-accessible programs, often referred to as Web applications. For example, there are a.html, b.html ... multiple Web resources, which are used to provide services externally, should be placed in a directory to form a Web application (or Web application)

A Web application consists of a number of static Web resources and dynamic Web resources, such as: HTML, CSS, JS files, JSP files, Java programs, support jar packages, configuration files, and so on.

After web application development, if you want to provide outside access, you need to give the Web application directory to the Web server management, this process called virtual directory mapping

1.3. Web History

Two stages of web development: static and dynamic

1.4. Static Web

*htm, *html, these are the suffix of the Web page, if you now read the content directly on a server, it means that the contents of these pages are presented to the user via a Web server. The process diagram for the entire static web operation is as follows:

In a static Web program, the client uses a Web browser (IE, Firefox, etc.) to connect to the server via a network (network), using the HTTP protocol to initiate a request, telling the server what page I need now, all the requests to the Web server, The Web server then extracts the content from the file system (the disk that holds all the static pages), depending on the user's needs. Then returned to the client through the Web server, the client received the content after the browser rendering resolution, the results are displayed.

  The following disadvantages exist in the static Web:

1, the content of the Web page can not be dynamically updated, all the users see the content and the final effect is the same.

In order to make the static web display more attractive, you can add JavaScript to complete some of the display effects on the page, but these effects are displayed to the user through the browser on the client, so there is no change on the server itself.

means to implement static Web client dynamic effects:

JavaScript

VBScript

JavaScript is used most in real-world development.

2, the static web can not connect to the database, can not implement and user interaction.

Using the database to save data is now the choice of most systems, because the database can easily manage the data, additions and deletions can be done using standard SQL statements.

1.5, Dynamic Web

The so-called dynamic does not mean that the page will move, the main feature is: "The Web page display effect because of people change," and Dynamic Web Interactive, Web page content can be dynamically updated. The process diagram for the entire dynamic web operation is as follows:

In the Dynamic web, the program still uses the client and the server, the client still uses the browser (IE, Firefox, etc.), connect to the servers over the network (network), use the HTTP protocol to initiate the request, and all the requests now go through a Web server Plugin (server plug-in), which is used to differentiate whether a static resource (*.htm or *.htm) or dynamic resource is requested.

If the Web server plugin discovers that the client is requesting a static resource (*.htm or *.htm), the request is forwarded directly to the Web server, which then extracts the content from the file system and sends it back to the client browser for resolution execution.

If the Web Server plugin discovers that the client is requesting dynamic resources (*.jsp, *.asp/*.aspx, *.php), the request is forwarded to the Web Container (Web container), and the database is connected to the Web Container. After a series of operations from the database, such as the dynamic patchwork of the content of the page, pieced together the content of the page, all the display content to the Web server, and then through the Web server to send content back to the client browser for resolution execution.

1.6, the implementation of Dynamic Web application means

Dynamic web is now implemented in a number of ways, the more common are the following:

Microsoft ASP, asp.net

PHP

Java servlet/jsp

1, Microsoft ASP, asp.net

Microsoft Dynamic Web Development is relatively early, and the earliest in the domestic most popular is the ASP. ASP is in the HTML language added VB Script, but the standard development application should be to use asp+com, but the actual situation, in the development of ASP, basically all in a page to write hundreds of code, the page code is extremely confusing.

The ASP itself has the limitation of development platform: Windows+iis+sql server/access,asp can only run on the Windows operating system, ASP is now basically eliminated, Now, basically, the asp.net is used for development, and the performance of the asp.net is greatly improved and developed quickly, but it is still limited by the platform. Asp. NET is mainly used in the C # language.

2.PHP

PHP Development is fast, powerful, Cross-platform (platform refers to the operating system), and the code is simple.

3.servlet/jsp

This is the implementation language of the B/s architecture, which Sun has now acquired by Oracle, and is based on the Java language, because the Java language is simple enough and clean.

The performance of servlet/jsp technology is also very high, is not limited by the platform, each platform can basically use. And in the running is the use of multithreading processing, so the performance is very high.

Sun Company launched the first web technology is a servlet program, the servlet program itself when the use of some problems, all programs are written in Java code +html, that is, to use Java output statements, one line to output all the HTML code, after , Sun Company was inspired by ASP, developed a JSP (Java Server Page), JSP some code writing effect and ASP is very similar. This makes it easy for some ASP programmers to turn to JSP learning, to increase the competitive strength of the market.

Second, the Web server

2.1. Introduction to Web Server

1. A Web server is a program that resides on some type of computer on the Internet and is a program that can provide documents to the requesting browser. When a Web browser (client) connects to the server and requests a file, the server processes the request and feeds the file to the browser, with information that tells the browser how to view the file (that is, the file type).

2. The server is a passive program: The server responds only if the browser on the Internet that is running on the other computer makes a request.


2.2, the common Web server Introduction

1, WebLogic

WebLogic is a application server produced by BEA company in the United States. The BEA WebLogic is a Java application server for developing, integrating, deploying, and managing large distributed Web applications, network applications, and database applications. Introduce Java dynamic capabilities and the security of Java Enterprise standards into the development, integration, deployment, and management of large network applications. is currently the most widely used Web server, support Java standard, and constantly improve to adapt to new development requirements, start the interface as shown

2. WebSphere

WebSphere Application Server is a full-featured, open WEB Application Server, a core part of IBM's E-commerce initiative, a java-based application environment for building, deploying, and managing Internet and Intranet Web Application. This entire suite of products has been scaled up to meet the needs of Web application servers, ranging from simplicity to advanced to enterprise level. Launch interface as shown:


3, Tomcat

Tomcattomcat is a minimal Web server that implements the Java EE Standard and is a core project of the Apache Software Foundation's Jakarta Project, developed by Apache, Sun, and other companies and individuals. Because Tomcat technology advanced, stable performance, and open source free, so deeply loved by the Java enthusiasts and has been recognized by some software developers, as the current more popular Web application server. Learning Javaweb development typically uses Tomcat servers, which support all JSP and servlet specifications, starting the interface as shown:

4, IIS

Microsoft's Web server product is Internet Information Services (IIS), which is a Web server that allows information to be published on a public intranet or on the Internet. Ⅱs is currently one of the most popular Web server products, many well-known sites are built on the Ⅱs platform. IIS provides a graphical interface management tool, called Internet Information Services Manager, that can be used to monitor configuration and control of Internet services.

IIS is a Web services component that includes Web servers, FTP servers, NNTP servers, and SMTP servers for Web browsing, file transfers, news services, and mail delivery, which makes it easy to post information on the network, including the Internet and local area networks. It provides an ISAPI (Intranet server API) as a programming interface for extending Web server functionality, and it also provides an Internet database connector that enables querying and updating of databases.

To learn about web development, you need to install a Web server and then develop the appropriate Web resources on your Web server for users to access using the browser.

Third, build Javaweb application development Environment--TOMCAT Server

3.1, the question: Learn Web development, why must install a Web server first?

Creating a Web page on the local computer is not accessible to users, but if the Tomcat server is started, the Web page is placed on a tomcat server and the user can access it. What's the problem?

1, no matter what web resources, want to be accessed by a remote computer, must have a corresponding network communication program, when the user to access, the network communication program read the Web resource data, and send the data to visitors.

2, the Web server is such a program, it is used to complete the underlying network communication. With these servers, we developers need to focus on how the Web resources are written, without caring how resources are sent to the client, thus greatly reducing developer effort.

3.2. Download and install Tomcat server

Tomcat Official site: http://jakarta.apache.org

Download Tomcat Installer package: http://tomcat.apache.org/

 

Click "Download" to jump to the download page as shown in the following figure


3.3. Start and test 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, input http://localhost:8080/, can show the following interface represents the successful installation.

  

3.4. Tomcat Startup FAQ

The reason that the Tomcat server does not start correctly is generally the following two:

1, Java_home environment variable setting problem

To start a Tomcat server by double-clicking the Startup.bat file in the bin directory, the first thing to do is to set the JAVA_HOME environment variable in Windows because the Tomcat server starts with this java_home environment variable, If the JAVA_HOME environment variable is not present in Windows, the Tomcat server cannot be started.

Configuring Java_home Variables in Windows

Operation Steps (Win7 system): Computer → right key "properties" → advanced system settings → advanced → environment variables, as shown in the following figure:

       

Click "New" under the system variable, pop up a new system Variable dialog box, first in the variable name Java_home, as the name implies, Java_home is the JDK installation path, and then write the JDK installation path in the variable value, such as the variable value set here is "d:\ Program Files (x86) \java\jdk1.7.0 ", set the value of the variable, click the" OK "button, Java_home environment variables are set to complete, as shown in the following figure: a" java_home "variable in the system variable.

Normally, the first step in learning JAVA development is to configure the PATH environment variable, which is better configured by first configuring the JAVA_HOME environment variable and then using "%java_home%" in the path variable to refer to the Java_home variable's value.

So this java_home environment variable is generally already configured in Windows, and if you forget to configure Java_home environment variables, you can configure the

2, port occupancy issues

Because the Tomcat server starts with the default of 8080 ports, if the 8080 port is occupied by another application, the Tomcat server does not start properly, seeing that the Tomcat server startup interface prints an exception error message and then shuts down automatically. , as shown in the following illustration:

  

Since this window is very short from boot to shutdown, it is very difficult to see the error message at Tomcat startup through this window, so we can generally view the operation of the Tomcat server through the log (log) information of the Tomcat server.

There is a logs folder under the root directory of the Tomcat server.

The logs folder holds Tomcat's log files, opens the Logs folder, and you can see the log file inside, which has a log file named "Catalina.yyyy-mm-dd.log", such as " The Catalina.2014-05-17.log log file is a recording of the operation of the Tomcat server for the day 2014-05-17.

Log information clearly records the operation of the Tomcat server, if because 8080 port is occupied and can not start normally, will be recorded as shown in the image above the exception information, by looking at the exception information, we can know why the Tomcat server can not start the normal!

Summary: When the Tomcat server does not start correctly, first check to see if the JAVA_HOME environment variable is configured, and then check that the port at the start of the Tomcat server is occupied by another application.

About Java Web Development Starter Book Example resolution (summary I) to introduce to you here, I hope to help you!

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.