servlet Redirection and Request forwarding

Source: Internet
Author: User

Set request redirection 1. You can select a different server-side program to process the request 2. Redirect the request to an exact URL setting automatic refresh and wait pages
response.setHeader("Refresh","time;URL=url");
The client browser sends a request to the server 1. Browser input Urk URL (get method) 2. Click the hyperlink (Get method) 3. Click Submit form (Get or POST method) The Get method and the Post method distinguish one. Commit data type get () text POST () text, Binary text two. Commit data length get () no more than 255 characters post () No limit three. Submit data visibility get () is displayed as part of the URL address in the browser address bar POST () as the requested message body, not visible four. Submit data Cache GET () Cached in Browser URL history status POST () will not be cached by the browser when using Get/post Method 1: Request a static page or graphics file. GET () 2: Send Big Data. POST () 3: Upload the file. POST () 4: Sends a user name, password, or other confidential information. POST () state Management 1. Hide Fields
缺点:必须是动态页面才有效
2.Cookie
优点:数据储存在客户端(动态页面和静态页面都有效),用户可以进入Cookie,Cookie可以删除.缺点:不安全
3.Session (session) Professional status management

1.可以通过设置时间(超时会消亡).2.手动销毁.3.Web服务器关闭(消亡).

# #ServletContext应用上下文
# # #1. Applications that belong to the entire web
# # #2. can access the local input stream to the Web application resource
# # #3. Convert the virtual path of a resource to a physical path
# # #4. Log Event Logs
# # #5. Binds an object to be shared throughout the Web application (all Servlets are accessible)
# #虚拟路径转换为物理路径
1.getResourcePaths (java.lang.String path);
2.getResourceAsStream (java.lang.String path);
3.getResource (java.lang.String path);
# #设置请求重定向
# # #1. You can select a different server-side program to process the request
# # #2. REDIRECT the request to a completely different URL
# #设置自动刷新和等待页
Response.setheader ("Refresh", "time; Url=url ");
# #客户端浏览器向服务器发送请求方式
# # #1. Browser input Urk URL (get method)
# # #2. Click the hyperlink (Get method)
# # #3. Click Submit form (Get or POST method)
# #get方法和post方法区别
# # #一. Submit data Type GET () text POST () text, binary text
# # #二. Submit data Length GET () No more than 255 characters POST () No Limit
# # #三. Submit data Visibility GET () is displayed as part of the URL address in the browser address bar POST () as the requested message body, not visible
# # #四. Submit data Cache GET () cache in browser URL history status POST () will not be cached by the browser
# #何时使用get/post method
# # #1: Request a static page or graphics file. GET ()
# # #2: Send Big Data. POST ()
# # #3: Upload files. POST ()
# # #4: Send a user name, password, or other confidential information. POST ()

# #状态管理
# # #1. Hide Fields
Cons: Must be dynamic page only valid
# # #2. Cookies
Advantages: Data stored in the client (dynamic pages and static pages are valid), users can enter Cookie,cookie can be deleted.
Cons: unsafe
# # #3. session (conversation) professional status management
1. You can set the time (timeout will die out).
2. Manually Destroy.
3.Web server shutdown (extinction).

servlet Redirection and Request forwarding

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.