Java Web-Servlet (1) Required knowledge

Source: Internet
Author: User

Learn the basic concepts necessary for Java WEB Development:

1.WEB

the intention is Spider webs and the meaning of the net, in the Web design we call the meaning of the page. is widely translated into the network, the Internet and other technical fields. Performance in three forms, hypertext (hypertext), hypermedia (hypermedia) , Hypertext Transfer Protocol (HTTP), and so on .

2. static Web page (can be easily understood as HTML)

The content of the Web page is fixed and will not change according to the different needs of the viewer. (Files that are actually saved on the server)

3. Dynamic Web pages

Refers to a page that is dynamically generated when a user accesses a request, and the content of the page changes with the access time and the visitor (not the Web page file that exists on the server independently, but only when the user requests that the server returns a full Web page), and the usual dynamic Web Development techniques: servlet->jsp,asp,PHP (LAMP)

4.b/S:

b/S structure (browser/server, Browser/Servermode), isWEBafter the rise of a network structure pattern,WEB Browser is ClientThe most importantapplication software. This pattern unifies theClient, the core part of the system function implementation is concentrated inServersimplifies the development, maintenance, and use of the system. On the client computer, install only oneBrowser, such asInternet Explorer,ServerinstallationSQL Server,Oracle,MYSQL and other databases. Browser data interaction with the database through Web Server.

That is, the user enters the URL, can be sent through the HTTP request to the server(Web Server), the server to judge the request, Transfer the corresponding code back to the client (user's browser)

5.C/s:

c/s   structure ( Client /server client / server client server structure. It is the software system architecture client End and server end to achieve, reducing the communication overhead of the system.

That is, the client and the server are written by the user's own code, the client can respond to the server message through the TCP/IP protocol, the server responds accordingly.

6.Web server

Refers to a Web server, which resides in Internet access a program on a type of computer that can provide documentation to Web clients, such as browsers, [1] You can also put the Web site files, let the world browse; You can place data files for download worldwide. At present, the most mainstream three Web servers are Apache,Nginx, IIS.

/ Medium-sized applications, you can use a free web server Span style= "font-family:arial" >:

Tomcat: a Java -developed JSP that conforms to the ee specification of the Servlet Server ( servlet container), is a Jsp/servlet container, is Apache the extension (for servlet/jsp ).

Download Tomcat and configure java_home (because tomcat is written in JAVA )

7. simulating a Web server

(1) write a webserver.java, compile and run the code as follows:

Import java.io.*;

Import java.net.*;

public class webserver{

public static void Main (string[] args) throws exception{

ServerSocket ss = new ServerSocket (8765);

System.out.println (" wait for connection on 8765 ... ");

while (true) {

Socket s = ss.accept ();

OutputStream OS = S.getoutputstream ();

BufferedReader br = new BufferedReader (New FileReader ("e:\\index.html"));

String buf = "";

while ((Buf=br.readline ()) = null) {

Os.write (Buf.getbytes ());

}

Br.close ();

Os.close ();

S.close ();

}

}

}

(2) under the D: Disk, write an HTML file with the following code:

<title>TestWebServer</title>

<body>

</body>

(3) The following results can be displayed in the browser input http://localhost:8765/ .

Tomcat 's directory structure:

Bin: start and close Tomcat script file (bat file)

There are two main categories, one with the end of . SH (linux command) and the other with . bat (windows command).

You can set the JDK path and modify the Catalina to set Tomcat 's memory.

-------------------------------------------------------

Conf (configuration): store various files configured for Tomcat

Server.xml: This file is used to configure and server -related information, such as the tomcat boot port, after configuring the Host

Configure the Context ( ie web app )

Web. xml: This file is configured to be a Web application ( Web app is the equivalent of a website )

Tomcat-users.xml: The file user configures the user password and permissions for Tomcat

-------------------------------------------------------

LIB: This directory places the jar packages required to run the Tomcat run

Logs: log file for Tomcat (can view startup, shutdown time, error message when error is available)WebApps (webapplications): Web the directory in which the application resides (that is, external access Web Storage Directory of resources)

Work: A post-compilation file that is used to store Tomcat at runtime, such as a JSP -compiled file.

Clearing The work directory, and then restarting Tomcat, can erase the cache.

Understand the basic composition of URLs and URIs :

URL (Uniform Resource Locator): The uniform resource Locator is yes to be available from the Internet A concise representation of the location and method of access to the resources on the Internet is the address of the standard resource on the web. Each file on the Internet has a unique URL that contains information that indicates the location of the file and how the browser should handle it.

protocol: tells the browser how to handle the file that will be opened. The most common pattern is the Hypertext Transfer Protocol (hypertext Transfer Protocol, abbreviated to HTTP), which can be used to access the network. Common:https,ftp,file,mailto

host (domain name): The name or IP address of the server where the file resides, followed by the path to the file and the name of the file itself.

URI : Uniform Resource Identifier (Uniform Resource Identifier, or URI) is a string that identifies the name of an Internet resource. This type of identification allows users to interact with any resource, including local and internet, through a specific protocol. the URI is defined by a scheme that includes a determination of syntax and related protocols.

Resources: HTML documents, images, video clips, programs, etc. .

W EB Applications:

W The EB Application is a collection of Web resources that can be understood as a directory on a hard disk that is used to manage multiple web Resources) are often referred to as Web applications, or Web projects.

a web The app consists of multiple web Resources or other files, including html file, CSS file, js file, dynamic web page, java Program, support jar package, configuration files and so on. Therefore, these different files should be stored according to certain specifications. Otherwise, the web Apps cannot be accessed and will cause web server failed to start.

W The composition of EB applications:





Java Web-Servlet (1) Required knowledge

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.