您当前的位置:首页 > 电脑百科 > 站长技术 > 服务器

JAVA手写tomcat,带你了解tomcat的原理,附代码

时间:2019-11-20 11:34:25  来源:  作者:

1 创建一个简单的servlet

代码示例:

package springmvc;

import JAVA.io.IOException;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

public class MyServlet extends HttpServlet{

/**

* 一个最简单的servlet

*/

private static final long serialVersionUID = 7683475760018217521L;

@Override

protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

String data="这是我的第一个servlet!";

System.out.println(data);

}

}

web.xml中的标签确定了servlet的访问路径

<!DOCTYPE web-App PUBLIC

"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

"http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>

<display-name>Archetype Created Web Application</display-name>

<servlet>

<servlet-name>littleServlet</servlet-name>

<servlet-class>springmvc.MyServlet</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>littleServlet</servlet-name>

<url-pattern>/servlet</url-pattern>

</servlet-mapping>

</web-app>

servlet完成之后需要需要将他打包成项目(war/jar),并解压完成,形成完整的项目目录,供后续自己写的Tomcat使用。通常情况下,所有的项目都会放入tomcat的webapps目录下。

开始手动编写tomcat代码

代码示例

package springboot.tomcat;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStream;

import java.io.InputStreamReader;

import java.io.OutputStream;

import java.io.PrintWriter;

import java.io.UnsupportedEncodingException;

import java.net.ServerSocket;

import java.net.Socket;

import java.security.Principal;

import java.util.Collection;

import java.util.Enumeration;

import java.util.Locale;

import java.util.Map;

import java.util.concurrent.ExecutorService;

import java.util.concurrent.Executors;

import javax.servlet.AsyncContext;

import javax.servlet.DispatcherType;

import javax.servlet.RequestDispatcher;

import javax.servlet.Servlet;

import javax.servlet.ServletContext;

import javax.servlet.ServletException;

import javax.servlet.ServletInputStream;

import javax.servlet.ServletOutputStream;

import javax.servlet.ServletRequest;

import javax.servlet.ServletResponse;

import javax.servlet.http.Cookie;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpSession;

import javax.servlet.http.HttpUpgradeHandler;

import javax.servlet.http.Part;

import springboot.util.ProjectUtil;

/**

* @author liuhongya328

*

*/

public class TomcatServer {

static int threads = 10;

private static ExecutorService pool = Executors.newCachedThreadPool();

/**

* @param args

*/

public static void main(String[] args) throws Exception{

//加载项目,获取tomcat需要发布的所有项目及项目下的所有servlet信息

final Map<String, ProjectUtil.WebXml> projectIno = ProjectUtil.load();

ServerSocket serverSocket = new ServerSocket(8080);

System.out.println("Tomcat 启动成功");

while(!serverSocket.isClosed()) {

//阻塞获取新连接

Socket socket = serverSocket.accept();

pool.submit(()->{

//接收数据

InputStream inputStream = socket.getInputStream();;

//请求响应结果

OutputStream outputStream = socket.getOutputStream();

try {

System.out.println("收到请求:-------");

BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "utf-8"));

String msg = null;

StringBuilder requestInfo = new StringBuilder();

while((msg = reader.readLine())!=null) {

if(msg.length()==0) {

break;

}

requestInfo.append(msg).append("rn");

}

System.out.println(requestInfo.toString()+"--------");

//请求需要访问的servlet,这个servlet相当于业务代码的controller,是需要放入tomcat中启动的项目,用原生的servlet便于从底层代码理解

//1.获取请求方式 及请求路径 GET /SpringMVC/servlet/littleServlet HTTP/1.1

String firstLine = requestInfo.toString().split("rn")[0];

String projectName = firstLine.split(" ")[1].split("/")[1];

String servletPath = firstLine.split(" ")[1].replace("/"+projectName, "");

//找到servlet对应的名称--j2ee规范

String servletName = projectIno.get(projectName).servletMapping.get(servletPath).toString();

//找到servlet对应的实例

Servlet servlet = (Servlet) projectIno.get(projectName).servletInstances.get(servletName);

//将socket的inputsteam 转成 request对象 ,如果想servlet接收和传递消息,需要实现自己的HttpServletRequest/HttpServletResponse即可。

//这里的创建仅作展示,实际没有作用,并不会传递socket的信息。

HttpServletRequest servletReuqest = createRequest();

HttpServletResponse servletResponse = createResponse();

//servlet的生命周期

servlet.service(servletReuqest, servletResponse);

outputStream.write("HTTP/1.1 200 OKrn".getBytes());

outputStream.write("Content-Length: 12rnrn".getBytes());

outputStream.write("Hello World!".getBytes());

outputStream.flush();

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

socket.close();

return null;

});

}

serverSocket.close();

}

private static HttpServletRequest createRequest() {

return new HttpServletRequest() {

@Override

public Object getAttribute(String name) {

// TODO Auto-generated method stub

return null;

}

@Override

public Enumeration<String> getAttributeNames() {

// TODO Auto-generated method stub

return null;

}

@Override

public String getCharacterEncoding() {

// TODO Auto-generated method stub

return null;

}

@Override

public void setCharacterEncoding(String env) throws UnsupportedEncodingException {

// TODO Auto-generated method stub

}

@Override

public int getContentLength() {

// TODO Auto-generated method stub

return 0;

}

@Override

public long getContentLengthLong() {

// TODO Auto-generated method stub

return 0;

}

@Override

public String getContentType() {

// TODO Auto-generated method stub

return null;

}

@Override

public ServletInputStream getInputStream() throws IOException {

// TODO Auto-generated method stub

return null;

}

@Override

public String getParameter(String name) {

// TODO Auto-generated method stub

return null;

}

@Override

public Enumeration<String> getParameterNames() {

// TODO Auto-generated method stub

return null;

}

@Override

public String[] getParameterValues(String name) {

// TODO Auto-generated method stub

return null;

}

@Override

public Map<String, String[]> getParameterMap() {

// TODO Auto-generated method stub

return null;

}

@Override

public String getProtocol() {

// TODO Auto-generated method stub

return null;

}

@Override

public String getScheme() {

// TODO Auto-generated method stub

return null;

}

@Override

public String getServerName() {

// TODO Auto-generated method stub

return null;

}

@Override

public int getServerPort() {

// TODO Auto-generated method stub

return 0;

}

@Override

public BufferedReader getReader() throws IOException {

// TODO Auto-generated method stub

return null;

}

@Override

public String getRemoteAddr() {

// TODO Auto-generated method stub

return null;

}

@Override

public String getRemoteHost() {

// TODO Auto-generated method stub

return null;

}

@Override

public void setAttribute(String name, Object o) {

// TODO Auto-generated method stub

}

@Override

public void removeAttribute(String name) {

// TODO Auto-generated method stub

}

@Override

public Locale getLocale() {

// TODO Auto-generated method stub

return null;

}

@Override

public Enumeration<Locale> getLocales() {

// TODO Auto-generated method stub

return null;

}

@Override

public boolean isSecure() {

// TODO Auto-generated method stub

return false;

}

@Override

public RequestDispatcher getRequestDispatcher(String path) {

// TODO Auto-generated method stub

return null;

}

@Override

public String getRealPath(String path) {

// TODO Auto-generated method stub

return null;

}

@Override

public int getRemotePort() {

// TODO Auto-generated method stub

return 0;

}

@Override

public String getLocalName() {

// TODO Auto-generated method stub

return null;

}

@Override

public String getLocalAddr() {

// TODO Auto-generated method stub

return null;

}

@Override

public int getLocalPort() {

// TODO Auto-generated method stub

return 0;

}

@Override

public ServletContext getServletContext() {

// TODO Auto-generated method stub

return null;

}

@Override

public AsyncContext startAsync() throws IllegalStateException {

// TODO Auto-generated method stub

return null;

}

@Override

public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse)

throws IllegalStateException {

// TODO Auto-generated method stub

return null;

}

@Override

public boolean isAsyncStarted() {

// TODO Auto-generated method stub

return false;

}

@Override

public boolean isAsyncSupported() {

// TODO Auto-generated method stub

return false;

}

@Override

public AsyncContext getAsyncContext() {

// TODO Auto-generated method stub

return null;

}

@Override

public DispatcherType getDispatcherType() {

// TODO Auto-generated method stub

return null;

}

@Override

public String getAuthType() {

// TODO Auto-generated method stub

return null;

}

@Override

public Cookie[] getCookies() {

// TODO Auto-generated method stub

return null;

}

@Override

public long getDateHeader(String name) {

// TODO Auto-generated method stub

return 0;

}

@Override

public String getHeader(String name) {

// TODO Auto-generated method stub

return null;

}

@Override

public Enumeration<String> getHeaders(String name) {

// TODO Auto-generated method stub

return null;

}

@Override

public Enumeration<String> getHeaderNames() {

// TODO Auto-generated method stub

return null;

}

@Override

public int getIntHeader(String name) {

// TODO Auto-generated method stub

return 0;

}

@Override

public String getMethod() {

//示例

return "GET";

}

@Override

public String getPathInfo() {

// TODO Auto-generated method stub

return null;

}

@Override

public String getPathTranslated() {

// TODO Auto-generated method stub

return null;

}

@Override

public String getContextPath() {

// TODO Auto-generated method stub

return null;

}

@Override

public String getQueryString() {

// TODO Auto-generated method stub

return null;

}

@Override

public String getRemoteUser() {

// TODO Auto-generated method stub

return null;

}

@Override

public boolean isUserInRole(String role) {

// TODO Auto-generated method stub

return false;

}

@Override

public Principal getUserPrincipal() {

// TODO Auto-generated method stub

return null;

}

@Override

public String getRequestedSessionId() {

// TODO Auto-generated method stub

return null;

}

@Override

public String getRequestURI() {

// TODO Auto-generated method stub

return null;

}

@Override

public StringBuffer getRequestURL() {

// TODO Auto-generated method stub

return null;

}

@Override

public String getServletPath() {

// TODO Auto-generated method stub

return null;

}

@Override

public HttpSession getSession(boolean create) {

// TODO Auto-generated method stub

return null;

}

@Override

public HttpSession getSession() {

// TODO Auto-generated method stub

return null;

}

@Override

public String changeSessionId() {

// TODO Auto-generated method stub

return null;

}

@Override

public boolean isRequestedSessionIdValid() {

// TODO Auto-generated method stub

return false;

}

@Override

public boolean isRequestedSessionIdFromCookie() {

// TODO Auto-generated method stub

return false;

}

@Override

public boolean isRequestedSessionIdFromURL() {

// TODO Auto-generated method stub

return false;

}

@Override

public boolean isRequestedSessionIdFromUrl() {

// TODO Auto-generated method stub

return false;

}

@Override

public boolean authenticate(HttpServletResponse response) throws IOException, ServletException {

// TODO Auto-generated method stub

return false;

}

@Override

public void login(String username, String password) throws ServletException {

// TODO Auto-generated method stub

}

@Override

public void logout() throws ServletException {

// TODO Auto-generated method stub

}

@Override

public Collection<Part> getParts() throws IOException, ServletException {

// TODO Auto-generated method stub

return null;

}

@Override

public Part getPart(String name) throws IOException, ServletException {

// TODO Auto-generated method stub

return null;

}

@Override

public <T extends HttpUpgradeHandler> T upgrade(Class<T> httpUpgradeHandlerClass)

throws IOException, ServletException {

// TODO Auto-generated method stub

return null;

}

};

}

private static HttpServletResponse createResponse() {

return new HttpServletResponse() {

@Override

public String getCharacterEncoding() {

// TODO Auto-generated method stub

return null;

}

@Override

public String getContentType() {

// TODO Auto-generated method stub

return null;

}

@Override

public ServletOutputStream getOutputStream() throws IOException {

return null;

}

@Override

public PrintWriter getWriter() throws IOException {

// TODO Auto-generated method stub

return null;

}

@Override

public void setCharacterEncoding(String charset) {

// TODO Auto-generated method stub

}

@Override

public void setContentLength(int len) {

// TODO Auto-generated method stub

}

@Override

public void setContentLengthLong(long length) {

// TODO Auto-generated method stub

}

@Override

public void setContentType(String type) {

// TODO Auto-generated method stub

}

@Override

public void setBufferSize(int size) {

// TODO Auto-generated method stub

}

@Override

public int getBufferSize() {

// TODO Auto-generated method stub

return 0;

}

@Override

public void flushBuffer() throws IOException {

// TODO Auto-generated method stub

}

@Override

public void resetBuffer() {

// TODO Auto-generated method stub

}

@Override

public boolean isCommitted() {

// TODO Auto-generated method stub

return false;

}

@Override

public void reset() {

// TODO Auto-generated method stub

}

@Override

public void setLocale(Locale loc) {

// TODO Auto-generated method stub

}

@Override

public Locale getLocale() {

// TODO Auto-generated method stub

return null;

}

@Override

public void addCookie(Cookie cookie) {

// TODO Auto-generated method stub

}

@Override

public boolean containsHeader(String name) {

// TODO Auto-generated method stub

return false;

}

@Override

public String encodeURL(String url) {

// TODO Auto-generated method stub

return null;

}

@Override

public String encodeRedirectURL(String url) {

// TODO Auto-generated method stub

return null;

}

@Override

public String encodeUrl(String url) {

// TODO Auto-generated method stub

return null;

}

@Override

public String encodeRedirectUrl(String url) {

// TODO Auto-generated method stub

return null;

}

@Override

public void sendError(int sc, String msg) throws IOException {

// TODO Auto-generated method stub

}

@Override

public void sendError(int sc) throws IOException {

// TODO Auto-generated method stub

}

@Override

public void sendRedirect(String location) throws IOException {

// TODO Auto-generated method stub

}

@Override

public void setDateHeader(String name, long date) {

// TODO Auto-generated method stub

}

@Override

public void addDateHeader(String name, long date) {

// TODO Auto-generated method stub

}

@Override

public void setHeader(String name, String value) {

// TODO Auto-generated method stub

}

@Override

public void addHeader(String name, String value) {

// TODO Auto-generated method stub

}

@Override

public void setIntHeader(String name, int value) {

// TODO Auto-generated method stub

}

@Override

public void addIntHeader(String name, int value) {

// TODO Auto-generated method stub

}

@Override

public void setStatus(int sc) {

// TODO Auto-generated method stub

}

@Override

public void setStatus(int sc, String sm) {

// TODO Auto-generated method stub

}

@Override

public int getStatus() {

// TODO Auto-generated method stub

return 0;

}

@Override

public String getHeader(String name) {

// TODO Auto-generated method stub

return null;

}

@Override

public Collection<String> getHeaders(String name) {

// TODO Auto-generated method stub

return null;

}

@Override

public Collection<String> getHeaderNames() {

// TODO Auto-generated method stub

return null;

}

};

}

}

获取项目信息的工具类

package springboot.util;

import java.io.File;

import java.net.URL;

import java.net.URLClassLoader;

import java.util.HashMap;

import java.util.Map;

import java.util.Map.Entry;

import javax.servlet.Servlet;

/**

*

* 加载项目信息

*

* */

public class ProjectUtil {

public static Map<String,WebXml> load() throws Exception{

final Map<String,WebXml> projetInfo = new HashMap<String,WebXml>();

//j2ee定义的是tomcat下的webapp目录,本地我取自己打包的war包目录

String webapps = "E:\learning\SpringMVC\SpringMVC\webapps";

//读取tomcat发布的所有的项目

File[] projects = new File(webapps).listFiles(projectName -> projectName.isDirectory());

for(File project : projects) {

//根据每个项目的web.xml读取servlet信息

WebXml webXml = new XMLConfigUtil().load(project.getPath()+"\WEB-INF\web.xml");

webXml.projectPath = project.getPath();

//类加载,加载class文件-----war包或者jar包中解压的class文件

webXml.loadServlet();

projetInfo.put(project.getName(), webXml);

}

return projetInfo;

}

public class WebXml{

public String projectPath = null;

//查找项目中所有的servlet

public Map<String,Object> servlets = new HashMap<String,Object>();

public Map<String,Object> servletMapping = new HashMap<String,Object>();

//实例对象

public Map<String,Object> servletInstances = new HashMap<String,Object>();

public void loadServlet() throws Exception {

//jvm加载class文件

URL url = new URL("file:"+projectPath+"\WEB-INF\classes\");

URLClassLoader classLoader = new URLClassLoader(new URL[] {url});

//加载servlet,创建servlet对象

for(Entry<String,Object> entry : servlets.entrySet()) {

//servlet的名称

String servletName = entry.getKey();

//servlet类的完整路径

String servletClassName = entry.getValue().toString();

//加载

Class<?> clazz = classLoader.loadClass(servletClassName);

//反射创建对象,这就是为什么j2ee规范 servlet要继承HttpServlet,

Servlet servlet = (Servlet) clazz.newInstance();

this.servletInstances.put(servletName, servlet);

}

}

}

}

解析web.xml的工具类

package springboot.util;

import java.io.IOException;

import java.util.HashMap;

import java.util.Map;

import javax.xml.parsers.ParserConfigurationException;

import javax.xml.parsers.SAXParser;

import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.Attributes;

import org.xml.sax.SAXException;

import org.xml.sax.helpers.DefaultHandler;

import springboot.util.ProjectUtil.WebXml;

public class XMLConfigUtil extends DefaultHandler {

// 查找项目中所有的servlet

public Map<String, Object> servlets = new HashMap<String, Object>();

public Map<String, Object> servletMapping = new HashMap<String, Object>();

// 实例对象

public Map<String, Object> servletInstances = new HashMap<String, Object>();

private String tag;// 存储操作的标签

private boolean isMapping = false;

private String currentServlet;

private String currentServletMapping;

public WebXml load(String path) throws SAXException, IOException, ParserConfigurationException {

// SAX解析

// 1、获取SAX解析工厂

SAXParserFactory factory = SAXParserFactory.newInstance();

// 2、从解析工厂中获取解析器

SAXParser parse = factory.newSAXParser();

XMLConfigUtil handler = new XMLConfigUtil();

// 5、解析

parse.parse(path, this);

// 6、获取数据

ProjectUtil.WebXml webXMl = new ProjectUtil().new WebXml();

webXMl.servlets = this.servlets;

webXMl.servletMapping = this.servletMapping;

return webXMl;

}

@Override

public void startDocument() throws SAXException {

}

@Override

public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {

if (null != qName) {

tag = qName;// 存储标签名

if (tag.equals("servlet")) {

isMapping = false;

} else if (tag.equals("servlet-mapping")) {

isMapping = true;

}

}

}

@Override

public void characters(char[] ch, int start, int length) throws SAXException {

String contents = new String(ch, start, length).trim();

if (null != contents) {// 处理空的问题

if (isMapping) {// 操作servlet-mapping

if (tag.equals("servlet-name")) {

currentServletMapping = contents;

} else if (tag.equals("url-pattern")) {

String urlPattern = contents;

servletMapping.put(urlPattern, currentServlet);

}

} else {// 操作servlet

if (tag.equals("servlet-name")) {

currentServlet = contents;

currentServletMapping = contents;

} else if (tag.equals("servlet-class")) {

String servletClass = contents;

servlets.put(currentServlet, servletClass);

}

}

}

}

}

说明

本次代码没有实现request和response是的交互,返回都是写死的outputStream.write(“Hello World!”.getBytes())。

如果需要实现,需要写自己的request和response。

JAVA手写tomcat,带你了解tomcat的原理,附代码


Tags:tomcat   点击:()  评论:()
声明:本站部分内容及图片来自互联网,转载是出于传递更多信息之目的,内容观点仅代表作者本人,如有任何标注错误或版权侵犯请与我们联系(Email:2595517585@qq.com),我们将及时更正、删除,谢谢。
▌相关推荐
1. 整体架构简析#如果将Tomca它的结构高度抽象的话,那么Tomcat其实可以看成只是有连接器(Connector)和容器(Container)两个组件构成。其中Connector组件负责在服务器端处理客户端...【详细内容】
2021-09-30  Tags: tomcat  点击:(54)  评论:(0)  加入收藏
开源的 Java Web 应用服务器,实现了 Java EE(Java Platform Enterprise Edition)的部 分技术规范,比如 Java Servlet、Java Server Page、JSTL、Java WebSocket。Java EE 是 S...【详细内容】
2021-09-17  Tags: tomcat  点击:(68)  评论:(0)  加入收藏
一、前言server.xml 配置,是 Tomcat启动配置,从配置结构可以看出 Tomcat 的整体架构。如果能够了解其常用配置项,对 Tomcat有一个高屋建瓴的把握,然后再庖丁解牛,一步步深入源码...【详细内容】
2021-07-04  Tags: tomcat  点击:(86)  评论:(0)  加入收藏
一,undertow介绍 1,undertow简介:Undertow是RedHAT红帽公司开源的产品,采用java开发,是一款灵活,高性能的web服务器,提供了NIO的阻塞/非阻塞API,也是Wildfly的默认Web容器。在javaw...【详细内容】
2021-05-07  Tags: tomcat  点击:(184)  评论:(0)  加入收藏
说明最近项目上遇到一些https的问题,需要在tomcat里面测试一下如何开启https协议访问网站,在网上查了一些资料,自己也试了很多次,终于成功搞定了,下面跟大家分享一下我的一点经验...【详细内容】
2021-04-20  Tags: tomcat  点击:(162)  评论:(0)  加入收藏
1 Jetty与glassfish的基本介绍1.1 研究背景及意义下图是对几个主流的应用服务器使用比率的粗率统计结果做出的一个饼图。这个图的数据也许不够精确,但它还是可以在一定程度上...【详细内容】
2021-04-06  Tags: tomcat  点击:(200)  评论:(0)  加入收藏
Tomcat是什么?Tomcat是web容器。你在做web项目时,多数需要http协议,也就是基于请求和响应,比如你在百度输入一行内容搜索,那么百度服务器如何处理这个请求呢,他需要创建servlet来...【详细内容】
2021-03-24  Tags: tomcat  点击:(290)  评论:(0)  加入收藏
有这样一个场景,公司为了安全起见,需要对所有登录Linux服务器做安全限制,要求除了管理员其他要登录linux服务器的员工不能用最高权限账号登录,要创建新的用户,对目录及文件权限做...【详细内容】
2021-03-04  Tags: tomcat  点击:(178)  评论:(0)  加入收藏
热部署就是在服务器运行时重新部署项目,热加载即在在运行时重新加载class,从而升级应用。通常情况下在开发环境中我们使用的是热加载,因为热加载的实现的方式在Web容器中启动一...【详细内容】
2021-03-03  Tags: tomcat  点击:(211)  评论:(0)  加入收藏
制作tomcat镜像先找到一个要安装的版本我们这里以拉取tomcat8的官方镜像为例 1:拉取官方镜像docker pull tomcat:8 2:查看镜像并启动tomcat容器docker imagesdocker run -d -p...【详细内容】
2021-03-01  Tags: tomcat  点击:(323)  评论:(0)  加入收藏
▌简易百科推荐
阿里云镜像源地址及安装网站地址https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b111kK44P更新源之前把之前的国外的镜像先备份一下 切换到yumcd...【详细内容】
2021-12-27  干程序那些事    Tags:CentOS7镜像   点击:(1)  评论:(0)  加入收藏
前言在实现TCP长连接功能中,客户端断线重连是一个很常见的问题,当我们使用netty实现断线重连时,是否考虑过如下几个问题: 如何监听到客户端和服务端连接断开 ? 如何实现断线后重...【详细内容】
2021-12-24  程序猿阿嘴  CSDN  Tags:Netty   点击:(12)  评论:(0)  加入收藏
一. 配置yum源在目录 /etc/yum.repos.d/ 下新建文件 google-chrome.repovim /etc/yum.repos.d/google-chrome.repo按i进入编辑模式写入如下内容:[google-chrome]name=googl...【详细内容】
2021-12-23  有云转晴    Tags:chrome   点击:(7)  评论:(0)  加入收藏
一. HTTP gzip压缩,概述 request header中声明Accept-Encoding : gzip,告知服务器客户端接受gzip的数据 response body,同时加入以下header:Content-Encoding: gzip:表明bo...【详细内容】
2021-12-22  java乐园    Tags:gzip压缩   点击:(9)  评论:(0)  加入收藏
yum -y install gcc automake autoconf libtool makeadduser testpasswd testmkdir /tmp/exploitln -s /usr/bin/ping /tmp/exploit/targetexec 3< /tmp/exploit/targetls -...【详细内容】
2021-12-22  SofM    Tags:Centos7   点击:(7)  评论:(0)  加入收藏
Windows操作系统和Linux操作系统有何区别?Windows操作系统:需支付版权费用,(华为云已购买正版版权,在华为云购买云服务器的用户安装系统时无需额外付费),界面化的操作系统对用户使...【详细内容】
2021-12-21  卷毛琴姨    Tags:云服务器   点击:(6)  评论:(0)  加入收藏
参考资料:Hive3.1.2安装指南_厦大数据库实验室博客Hive学习(一) 安装 环境:CentOS 7 + Hadoop3.2 + Hive3.1 - 一个人、一座城 - 博客园1.安装hive1.1下载地址hive镜像路径 ht...【详细内容】
2021-12-20  zebra-08    Tags:Hive   点击:(9)  评论:(0)  加入收藏
以下是服务器安全加固的步骤,本文以腾讯云的CentOS7.7版本为例来介绍,如果你使用的是秘钥登录服务器1-5步骤可以跳过。1、设置复杂密码服务器设置大写、小写、特殊字符、数字...【详细内容】
2021-12-20  网安人    Tags:服务器   点击:(7)  评论:(0)  加入收藏
项目中,遇到了一个问题,就是PDF等文档不能够在线预览,预览时会报错。错误描述浏览器的console中,显示如下错误:nginx代理服务报Mixed Content: The page at ******** was loaded...【详细内容】
2021-12-17  mdong    Tags:Nginx   点击:(7)  评论:(0)  加入收藏
转自: https://kermsite.com/p/wt-ssh/由于格式问题,部分链接、表格可能会失效,若失效请访问原文密码登录 以及 通过密钥实现免密码登录Dec 15, 2021阅读时长: 6 分钟简介Windo...【详细内容】
2021-12-17  LaLiLi    Tags:SSH连接   点击:(16)  评论:(0)  加入收藏
最新更新
栏目热门
栏目头条