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 Web page.

is widely translated into the network, the Internet and other technical fields. Three forms of hypertext (hypertext), hypermedia (hypermedia), Hypertext Transfer Protocol (HTTP), and so on .

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

Refers to the content of the Web page is fixed, not according to the browser's different needs and changes. (Files that are actually saved on the server)

3. Dynamic Web pages

Refers to a dynamically generated page after receiving a user's access to the request. The content of the page changes as the access time and the visitors change (not a Web page file that exists on the server alone, only the server returns a full page when the user requests it), and the dynamic Web Development techniques that are often used: servlet->jsp,asp,PHP (LAMP)

4.b/S:

b/S structure (browser/server. Browser /server mode). is a network structure model after the rise of web,Web Browser is the most basic application software of client .

Such a model unifies the client. The core part of the system function is centralized to the server , which simplifies the development, maintenance and use of the system.

Only one browser , such as Internet Explorer, is installed on the client. Server installs databases such as SQL Server,Oracle,MYSQL , and so on.

Browser data interaction with the database through Web Server.

That is, the user enters the URL. Can be sent to the server(Webserver) through an HTTP request ,and the server infers 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 server end to achieve, reducing the communication overhead of the system.

That is, both client and server are code that the user writes themselves, and the client responds to the server message through the TCP/IP protocol, and the server responds again.

6.Webserver

generally referred to as Site server. Refers to A program that resides on some type of computer on the Internet. The ability toprovide documentsto Webclients such as browsers,[1] can also place site files for browsing around the world. Ability to place data files. Let the world download. The most mainstream three Webservers are Apache,Nginx, IIS .

/ Medium-sized applications, the ability to 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 an Apache extension (for servlet/jsp).

Download Tomcat and configure java_home (as Tomcat is written in JAVA )

7. Simulate a Webserver

(1) write a webserver.java, compile, execute code such as the following:

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 code such as the following:

<title>TestWebServer</title>

<body>

</body>

(3) in the browser input http://localhost:8765/ can show the following effect.

the folder structure of Tomcat:

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

There are two main categories, one of which is the end of the . Sh (linux command). There is also a category that ends with a . bat (Windows command).

Ability to set JDK path, change 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. For example , after Tomcat starts port. Configure Host

Configure the Context ( ie web app )

Web. xml: This file is configured to be a Web site (web App )

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

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

LIB: This folder places the jar packages needed to perform Tomcat execution

Logs: A log file that holds Tomcat (can be viewed for startup.) Closing time. When there is an error. Queryable error message)WebApps (webapplications): the folder in which the Web application resides (that is , the folder of Web resources for external access)

Work: A post-compilation file that is used to store Tomcat at execution time. For example , JSP compiled files.

Empty The work folder and restart Tomcatto get rid of the cache.

Understand the basic composition of URLs and URIs :

URL (Uniform Resource Locator): The uniform resource Locator is to be available from the Internet The location of the available resources and a concise representation of the access methods are the addresses of the standard resources on the Internet. Every file on the Internet has a unique URL. It includes information that indicates the location of the file and how the browser should handle it.

protocol: tell the browser how to handle the file that will be opened.

The most frequently used mode 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. The identity agrees that the user interacts with a specific protocol for any resource (including both local and internet).

URI defined by a scenario that contains a deterministic syntax and related protocols.

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

W EB Applications:

W an EB application is a collection of Web resources that can be understood as a folder on a hard disk. This folder is used to manage multiple Web resources, often referred to as Web applications, or Webproject.

A web app consists of multiple Web Resources or other files, including HTML files,css files , JS files, dynamic Web pages, Java programs, Support Jar packages, configuration files, and so on. Therefore, these different documents should be stored according to certain specifications. Doing so may prevent Web apps from visiting , and will cause Webserver to fail 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.