One of the Javaweb development series "web server"

    Web introductory knowledge


WEB, in English, web means webpage, and it is used to represent resources on the Internet host for outside access.

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

  • Static web resources (such as html pages): Refers to the data in the web page for people to browse is always the same.

       Note: mainly refers to HTML

  • Dynamic web resources: refers to the data in the web page for people to browse is generated by the program, and the content seen when visiting the web page at different time points is different.

       Note: JSP/Servlet, ASP, PHP, etc. In Java, dynamic web resource development technologies are collectively referred to as Javaweb

Two architectures of software development: c/s and b/s

 

Introduction to the server


Physically speaking, the server is a PC machine. Usually the configuration is relatively high. CPU 4 cores, memory above 8G, hard disk T level, basic classification:

  1. Web server: On the PC machine, web service software is installed to provide web services
  2. Database server: The database software (mysql/oracle/sql server) is installed on the PC machine to provide data storage services
  3. Mail server: On the PC machine, the mail service software is installed to provide the function of receiving and sending mail

        Incoming mail server: pop3.126.com

        Outgoing mail server: stmp.126.com

Among them, the main function of the web server is to expose local resources to external access

The simple communication code of Javaweb is as follows

/**
 * @FileName SocketServer.java
 * @Desciption TODO
 * @author GXBOYS
 * @date 2018年7月17日
 */
package com.lance.blogs.web;

import java.io.File;
import java.io.FileInputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @Description socket服务器端程序
 * 1)把本地资源读取
 * 2)发送给不同的客户端
 * @author GXBOYS
 * @date 2018年7月17日
 */
public class SocketServer
{
    public static void main(String[] args) throws Exception
    {
        //1.创建ServerSocket
        ServerSocket server = new ServerSocket(8888);
        System.out.println("服务器已经启动....");
        while (true)
        {
            //2.接收客户端的请求
            Socket socket = server.accept();

            //3.读取本地的文件
            File file = new File("D:/myBlogs/test.html");
            FileInputStream fis = new FileInputStream(file);

            //4.构建数据发送通道
            OutputStream out = socket.getOutputStream();

            //5.开始发送数据
            byte[] buf = new byte[1024];
            int len = 0;
            while ((len = fis.read(buf)) != -1)
            {
                out.write(buf, 0, len);
            }

            //6.关闭资源
            fis.close();
            out.close();
        }
    }
}

 

Common web server


A web server can also be called a web container. Commonly used web containers are:

  • WebLogic:是美国Oracle公司(收购BEA公司)出品的一个application server,确切的说是一个基于JAVAEE架构的中间件,WebLogic是用于开发、集成、部署和管理大型分布式Web应用、网络应用和数据库应用的Java应用服务器。将Java的动态功能和Java Enterprise标准的安全性引入大型网络应用的开发、集成、部署和管理之中。是目前应用最广泛的Web服务器,支持J2EE规范,而且不断的完善以适应新的开发要求。

         启动界面如图

        

 

 

         javaSE规范:支持 IO流,集合,网络编程,线程技术

         javaEE规范: 支持13种技术。Servlet、Jsp、EJB、JDBC、JavaMail等

  • WebSphere: 是 IBM 的软件平台,支持J2EE规范,它包含了编写、运行和监视全天候的工业强度的随需应变 Web 应用程序和跨平台、跨产品解决方案所需要的整个中间件基础设施,如服务器、服务和工具。WebSphere 提供了可靠、灵活和健壮的软件。

       启动界面如图

      

      收费的软件。

  • JBoss: 是一个基于J2EE的开放源代码应用服务器。 JBoss代码遵循LGPL许可,可以在任何商业应用中免费使用。JBoss是一个管理EJB的容器和服务器,支持EJB 1.1、EJB 2.0和EJB3的规范。但JBoss核心服务不包括支持servlet/JSP的WEB容器,一般与Tomcat或Jetty绑定使用。

       启动界面如图:

      

  • Tomcat: 是Apache 软件基金会(Apache Software Foundation)的Jakarta 项目中的一个核心项目,由Apache、Sun 和其他一些公司及个人共同开发而成。由于有了Sun 的参与和支持,最新的Servlet 和JSP 规范总是能在Tomcat 中得到体现,Tomcat 5支持最新的Servlet 2.4 和JSP 2.0 规范。因为Tomcat 技术先进、性能稳定,而且免费,因而深受Java 爱好者的喜爱并得到了部分软件开发商的认可,成为目前比较流行的Web 应用服务器。

       启动界面如图:

      

       注:Tomcat和Java的兼容性最好,不完全支持JavaEES规范,支持servlet/jsp规范(不支持ejb)。

  • IIS: iis是Internet Information Services的缩写,意为互联网信息服务,是由微软公司提供的基于运行Microsoft Windows的互联网基本服务。最初是Windows NT版本的可选包,随后内置在Windows 2000、Windows XP Professional和Windows Server 2003一起发行,但在Windows XP Home版本上并没有IIS。IIS是一种Web(网页)服务组件,其中包括Web服务器、FTP服务器、NNTP服务器和SMTP服务器,分别用于网页浏览、文件传输、新闻服务和邮件发送等方面,它使得在网络(包括互联网和局域网)上发布信息成了一件很容易的事。但是IIS的安全脆弱性曾长时间被业内诟病,一旦IIS出现远程执行漏洞威胁将会非常严重。远程执行代码漏洞存在于 HTTP 协议堆栈 (HTTP.sys) 中,当 HTTP.sys 未正确分析经特殊设计的 HTTP 请求时会导致此漏洞。 成功利用此漏洞的攻击者可以在系统帐户的上下文中执行任意代码,可以导致IIS服务器所在机器蓝屏或读取其内存中的机密数据。

      启动界面如图:

     

     注:Java开发不适用IIS服务器。

 

Java学习阶段,主要使用Tomcat服务器,以下会详细介绍该容器。

本文为原创博客,转载请说明出处,感谢!!

Guess you like

Origin blog.csdn.net/dgxin_605/article/details/81090007