Java EE web programming (1)

Source: Internet
Author: User
Tags website server apache tomcat
Build a development environment and download the software toolkit

1. Download JDK (download and install JDK from http://www.oracle.com/technetwork/java/javase/downloads/index.html). Here we download and install JDK 1.6. After installation is complete, add a system variable java_home, pointing to JDK home directory 1. Then, after the system variable path, add the lib directory under the current directory "." And JDK main directory, 2.


Figure 1 Figure 2

2. Download and install Tomcat

Download (http://tomcat.apache.org/) Tomcat get a compressed package, extract to disk, add the system variable catalina_home, point to the decompressed Tomcat directory, 3, add the lib directory under the Apache Tomcat main directory after the system variable path, as shown in figure 4.


Figure 3 Figure 4

3. Download and install eclipse

Download eclipse (http://www.eclipse.org/downloads/), here to download the Eclipse IDE for Java EE developers version, download the package to decompress it.

Test whether JDK is correctly installed. Use win + R to call up the command line and type the Java-version command. If the Java version is displayed, the installation is correct. 5.

Test whether Tomcat is correctly installed. Open eclipse and create a new project: file --> New --> project. If a dynamic web project is issued in the Web category, the installation of Tomcat is correct.


Figure 5

Prerequisites 1. http protocol

First of all, you need to understand the basic HTTP protocol knowledge. For details, refer to the HTTP protocol specifications. However, several common knowledge points must be known.

A. the HTTP protocol works over TCP and belongs to the application layer protocol.

B. the HTTP protocol is connectionless and stateless.

C. the HTTP protocol supports multiple request methods, but the most common get and post requests are different from each other. The GET request method generally does not modify server resources, the post method generally modifies the server resources, and can regard get as "read, and post as" write.

2. url syntax format

The importance of a URL determines that it must be listed separately. The following url text comes from the Baidu entry. On WWW, each information resource has a unified and unique address on the Internet. This address is called URL (Uniform Resource Locator, unified Resource Locator ), it is the unified resource positioning mark of WWW, that is, the network address. A URL consists of three parts: resource type, host domain name for storing resources, and resource file name.

The URL syntax is as follows:

(Optional with square brackets ):

Protocol: // hostname [: Port]/path/[; parameters] [? Query] # Fragment

For example:

Http://www.imailtone.com: 80/webapplication1/webform1.aspx? Name = Tom &; age = 20 # resume

Format description

1. Protocol (Protocol)

The following table lists the valid protocol names for the Protocol attribute. HTTP is the most commonly used protocol. It is also the most widely used protocol for WWW.

File resources are files on the local computer. Format File ://

Ftp accesses resources through FTP. Format ://

Wait ..........

2. hostname (host name)

It refers to the host name or IP address of the Domain Name System (DNS) of the server that stores resources. Sometimes, the host name can contain the username and password required to connect to the server (Format: username @ password ).

3. Port (port number)

INTEGER (optional) Default port used when the scheme is omitted. All transmission protocols have default port numbers, for example, HTTP's default port is 80. If this parameter is omitted, the default port number is used. For security or other considerations, You can redefine the port on the server, that is, use a non-standard port number. In this case, the port number cannot be omitted in the URL.

4. Path)

A string separated by zero or multiple "/" symbols. It is generally used to represent a directory or file address on the host.

5. parameters (parameters)

This is optional for specifying special parameters.

6. Query)

Optional. Used for dynamic web pages (such as CGI, ISAPI, PHP/JSP/asp. net and other technologies) Transfer Parameters, can have multiple parameters, separated by the "&" symbol, each parameter name and value are separated by the "=" symbol.

7. Fragment)

String used to specify fragments in network resources. For example, if a webpage contains multiple glossary, you can use fragment to directly locate the glossary.

3. Session and cookie

Because the HTTP protocol is stateless, there must be some way to save the status. Various web programming methods provide similar means, but all of them support session and cookie. There are many similarities between the two. First, they are both ways to save information. Both adopt a mechanism similar to the hash mechanism to store information in the form of name-value pairs, both have a certain life cycle. The difference is that cookie is a client mechanism, and the cookie information is stored on the customer's hard disk. When the customer's browser accesses a website that has been visited, the cookie is sent to the website, and the website server can use the cookie to obtain some required information. Session is a server mechanism in which session information is stored on the server. The session life is usually about 20 minutes shorter. During session persistence, the server can access the information of the corresponding customers.

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.