[Java] [Web] Response Learning. Caching

Source: Internet
Author: User

Response.setheader ("Expires", String.valueof (System.currenttimemillis () + $ * 3600= "AAAAA"; Response.getwriter (). write (datastring);

If the code above, plus the expires time, is equivalent to caching the resource.

// implement the Request redirection method one response.setstatus (302); Response.setheader ("Location", "/day06"); // implement the Request redirection method two response.sendredirect ("/day06");

Both of these methods are sent requests redirected to the/DAY06 page. The server will receive two requests and the browser address bar will change.

Each time the browser refreshes, the last action is resubmitted, and redirection avoids the problem.

 http Status 500- Getoutputstream () have already been called for this response  type Exception reportmessage getoutputstream () have Alrea Dy been called for this responsedescription the server encountered a internal error that prevented it from fulfilling thi S Request.exceptionjava.lang.IllegalStateException:getOutputStream () have already been called for this response Org.apa    Che.catalina.connector.Response.getWriter (response.java:662)    Org.apache.catalina.connector.ResponseFacade.getWriter (responsefacade.java:213) Cn.itcast.response.ResponseDemo8.doGet (responsedemo8.java:27) Javax.servlet.http.HttpServlet.service (    httpservlet.java:624) Javax.servlet.http.HttpServlet.service (httpservlet.java:731) Org.apache.tomcat.websocket.server.WsFilter.doFilter (wsfilter.java:52) Note the full stack trace of the root cause is Available in the Apache tomcat/7.0.77 logs.  
This is a common exception because Response.getoutputstream () is used in the code snippet at the same time; and Response.getwriter ();

[Java] [Web] Response Learning. Caching

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.