Java Web Foundation Summary three--java Web server

Source: Internet
Author: User
Tags gz file tomcat server websphere application server

Java Web Foundation Summary three--java Web serverA. What is a Java Web server

First look at what is a Web server, which generally refers to a Web server, refers to a re-internet on a host on a program. It resolves requests sent by the client to comply with the HTTP protocol and, after logical business processing, provides documents to Web clients, such as browsers, in the HTTP protocol.

Web resources on the Internet for external access can be divided into two types: a static Web resource (such as an HTML page) that is always the same for people to view in a Web page. Another dynamic Web resource, refers to the Web page for people to browse the data is generated by the program, different times to access the Web page to see the content of the various, the current Web page is basically dynamic. Common Dynamic Web Resources development technology: Jsp/servlet, ASP, PHP and so on.

In general, we refer to the development of dynamic Web pages as Javaweb technology, so the usual Java Web server can also be considered as a container that follows all Jsp/servlet specifications. The so-called container is that it implements the Java-defined Jsp/servlet interface specification, which can be managed for the entire life cycle of jsp/servlet creation, operation, and destruction.

The implementation of the servlet container is very complex. However, there are three main processes implemented: first create a Request object that implements the Javax.servlet.ServletRequest interface or Javax.servlet.http.ServletRequest interface, and uses the request parameters, Request headers (headers), cookies, query strings, URIs, and so on to populate the Request object; Creates a Response object that implements the Javax.servlet.ServletResponse or Javax.servlet.http.ServletResponse interface, invokes the service method of the corresponding servlet, and creates the previously created The request object and the response object are passed in as parameters. The servlet that receives the request reads information from the requests object and writes the return value to the response object. The response object is then converted to HTTP messaging to the client.

two. Implement one of the simplest Java Web servers yourself

Since the HTTP protocol is based on the TCP/IP protocol, it is possible to implement a very simple HTTP server using only ServerSocket and sockets. Here is a simple, rudimentary HTTP server similar to Hello World. The request is not processed, and Hello World is returned for all client requests.

Package Com.c;import Java.io.ioexception;import Java.io.printwriter;import java.net.serversocket;import Java.net.socket;public class Httpserver {public    static void Main (string[] args) {        try {            ServerSocket Serversocket=new ServerSocket (8080);            while (true) {                Socket socket=serversocket.accept ();                System.out.println ("-------");                PrintWriter printwriter=new PrintWriter (Socket.getoutputstream ());                Encapsulates the HTTP response message                printwriter.println ("http/1.1");                Printwriter.println ("content-type:text/html");                Printwriter.println ();                Send Hello World                printwriter.println ("

three. A few common Java Web servers 1. WebLogic

WebLogic is Bea's product, is currently the most widely used Web server, support the Java EE specification, of course, is commercial, so need to pay.

2. WebSphere

It is developed by IBM and supports the Java EE specification. Generally used for insurance, banking and other core trading system. Many of the business systems that are associated with money are WebSphere application Server. So the performance is high, the same is not free.

3. Apache

Apache Open source organization has a very good open source Web server: Tomcat, in a small application system is widely used, the server supports all JSP and servlet specifications, and now a lot of commercial companies are also used in the production environment.

Four. About Tomcat Server1. Tomcat Installation

It is: http://tomcat.apache.org/. When downloading, the tar.gz file is the installation version under the Linux operating system. The zip file is a compressed version under Windows System. For Windows versions, after downloading, unzip directly, double-click the Startup.bat file under the Bin directory, or start with a command at the command line. Input http://localhost:8080/a three-legged Tom Cat is on the stand for installation success.

2. Tomcat's directory hierarchy:


Our Web projects are deployed to the WebApps directory. Then Tomcat will manage it automatically. This directory can be used to deploy multiple projects at the same time, but a generic production environment will deploy only one project in a Tomcat instance.

Java Web Foundation Summary three--java Web server

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.