Interview [JAVA] Web and network basis


1, the difference between forward and redirect

  1. Server resource request is forwarded, direct access to the target server address url, the response content back to the browser. The re-request redirection address status code returned by the server.
  2. Forwarding server behavior, redirect the client behavior.
  3. url forwarding to redirect the display does not change and display the new url.
  4. Forwarding page to page forward and share information request, the redirect do not share data.
  5. Generally used for forwarding user logs in, the response is forwarded to the module according to the role, generally used to redirect the user logs off, jump to another place.

    2, TCP three-way handshake

    Three-way handshake to establish a TCP connection:

  • Syn client sends a connection request to the server.
  • Server sends syn ack to the client awarded connections.
  • The client sends ack confirm the connection to the server.

The first client to confirm their normally transmitted, the server to confirm their normal reception.
The second server to confirm their sending, receiving normal, the client sends normal. The client confirm their sending, receiving normal transmission, the server, and accept normal.
Third Client Server have confirmed both the sending and receiving of normal.

3, TCP four wave

  1. Fin client sends to the server, the data transfer off of the client to the server.
  2. Server sends ack.
  3. Server sends fin, close the connection server and client.
  4. The client sends ack, the connection is closed.

4. Why is the three-way handshake fourth wave

When the connection is established, syn and ack can be sent at the same time, but when disconnected fin and ack can not be sent at the same time, because the server has not yet confirmed whether all packets are sent over, all packets sent over to send fin. Therefore, establishing a connection requires three-way handshake, the need to disconnect the fourth wave.

5 difference, TCP and UDP,

  1. TCP protocol is a connection must be established via three-way handshake, UDP is a connectionless.
  2. TCP guarantees data arrive out of order, UDP is not guaranteed.
  3. TCP is a service-oriented byte stream, UDP is a message-oriented service.

6, what is the Servlet

Intermediate layer between the http request and procedures. Client requests to read data, process the data and generate a result.

7, the difference between the interceptor and the filter

  1. Interceptor Based on java reflection implemented callback, the filter.
  2. Interceptor does not depend Servlet Container, the filter dependent Servlet.

实现一个拦截器继承HandlerIntecepterAdapter。
实现过滤器继承Filter,在web.xml中进行配置。

8、HTTPS的过程

  1. 客户端发起https请求,建立连接,发送所支持的ssl/tls的版本,支持的加密套件等。
  2. 服务器收到请求后,会发送服务端的证书,选择的ssl/tls的版本,使用的加密套件。
  3. 客户端收到证书之后对证书进行验证,验证证书是否被篡改,验证证书的有效期。获取服务器的公钥。
  4. 使用服务器的公钥对一个随机数进行加密,传送给服务器。
  5. 然后使用这个随机数进行对称加密进行传输数据。

9、加密相关

  • 对称加密
    加解密使用同一套秘钥,常用的加密算法: AES、 DES。
  • 非对称加密
    指的是加解密使用不同的密匙,一个公钥一个私钥。公钥加密的信息只有私钥能解开,私钥加密的信息只有公钥能解开。
  • 摘要
    一段信息,经过摘要算法得到一串hash值。常用的摘要算法:MD5、SHA1、SHA256。
  • 数字签名
    先用摘要算法,获取内容的摘要,之后使用自己的私钥对摘要进行加密生成签名。
  • 数字证书
    证书有签发者、证书用途、公钥、加密算法、hash算法、到期时间等。数字证书会做一个数字签名防止证书被篡改。会用CA的私钥进行加密。CA的公钥是公开的,浏览器会缓存。

tencent.jpg

Guess you like

Origin www.cnblogs.com/clawhub/p/12064449.html