Home  >  Article  >  Java  >  What is servlet redirection

What is servlet redirection

清浅
清浅Original
2019-05-06 11:51:514846browse

Servlet redirection refers to a mechanism specified by the http protocol. The workflow is: 1. The client initiates an http request and accesses the server-side component; 2. The server returns a 302 status code as the response result; 3. . When the browser receives this result, it will automatically access the new URL; 4. The browser accepts the new URL and returns the result.

What is servlet redirection

What is redirection?

The redirection mentioned here is a mechanism specified by the http protocol. The workflow is described below.

(1) The client initiates an http request and accesses the server-side components.

(2) The server returns a response result with status code 302. The meaning of this code is to let the browser access another component, and the response result contains the URL address of accessing the new component. The new access component may or may not be in the same application.

(3) When the browser receives this result, it will automatically access the new URL.

(4) The browser accepts the new URL and returns the result.

Implementation

Redirection is completed through the sendRedirect (String location) method provided by the HttpServletReponse interface in the Servlet API.

Redirect Features

(1) The response result of the servlet source component will not be returned to the client.

(2) The servlet source component and the target component will not share the same ServletRequest object.

(3) If the source component submits the response result in advance before redirection, an exception will be reported.

(5) The redirected address does not have to be the application of the same server.

The above is the detailed content of What is servlet redirection. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What is Spring CloudNext article:What is Spring Cloud