Response. setheader usage

Source: Internet
Author: User

Refresh the page once every second. response. setheader ("refresh", "1 ");

2 seconds to jump to other pages response. setheader ("refresh", "2; url = otherpagename ");

No cache:
Response. setheader ("Pragma", "No-Cache ");
Response. setheader ("cache-control", "No-Cache ");

Set the expiration time
Response. setdateheader ("expires", system. currenttimemillis () + time period set by yourself );

Access other pages: Response. setstatus (302); response. setheader ("location", "url ");

The compression format used by the notification Browser: Response. setheader ("content-encoding", "compressed data ");
Length of compressed data in High-Speed browsers: Response. setheader ("Content-Length", compressed data. Length + "");


High-speed browser images or videos: Response. setheader ("Content-Type", "this parameter is found in Web. xml under conf in Tomcat ");

Inputstream in = This. getservletcontext. getresourceasstream ("/2.jpg ");
Int Len = 0;
Byte buffer [] = new byte [1, 1024]

Outputstream out = response. getoutputstream ();

While (LEN = in. Read (buffer)> 0 ){
Out. Write (buffer, 0, Len)
}


The high-speed browser has downloaded the form: Response. setheader ("content-disposition", "attachment?filename=2.jpg ");

Inputstream in = This. getservletcontext. getresourceasstream ("/2.jpg ");
Int Len = 0;
Byte buffer [] = new byte [1, 1024]

Outputstream out = response. getoutputstream ();

While (LEN = in. Read (buffer)> 0 ){
Out. Write (buffer, 0, Len)
}

Response. setheader usage

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.