English 中文(简体)
请对以下3项发言作出解释,并解释何时在jsp中使用这些发言? [非公开]
原标题:Please give explanation for below 3 statements and when to use them in jsp? [closed]
  • 时间:2012-05-25 06:07:01
  •  标签:
  • jsp
最佳回答

您需要设置适当的 HTTP 信头属性, 以防止浏览器缓存 JSP 页面的动态内容输出。 您可以在您的 JSP 页面的起始处执行以下脚本来做到这一点, 以防止它们在浏览器中缓存 。 您需要这两个语句来处理一些旧的浏览器版本 。

<%
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>

在 HTML 页眉中使用元标记可以达到同样效果:

<meta http-equiv="Pragma" content="no-cache">
 <meta http-equiv="Cache-Control" content="no-cache">
 <meta http-equiv="Expires" content="Thu, 01 Dec 2011 00:00:00 GMT">

更多信息请查阅

问题回答

这些缓存控制设置可用于您不希望浏览器在本地存储内容的页面。 大多数网络开发者不想使用这些页面, 因为它们可能对性能产生消极影响。 您可能想要使用这些缓存控制设置的示例是, 当您拥有大量动态资源时 。

过期标记告诉浏览器页面完成后过期 。 “ 因此, 确定 EXPIRES 到 0 可用于强制每次访问时进行修改检查 。 ”





相关问题
Convert typed-in Text to lowercase

I ve got an index.jsp with [snip] <% String name = request.getParameter("name"); String pass = request.getParameter("pass"); String globalname = "webeng"; String globalpass = "2009"; ...

session transfer issue from Tomcat to ASP.Net

I am using Tomcat to host JSP and using IIS 7.0 to host aspx (C# + .Net 3.5 + VSTS 2008), and I have some session transfer issue from JSP page to ASPX page. JSP page is in one domain and all other ...

Setting the default value in Struts2

I am setting the value(kind of default value) for a drop down select value from action class in a page(given below). When the page loads the value is beig displayed but the other elements of the ...

Evaluate dynamically constructed JSP at runtime

I have a requirement where in the JSP page itself is created by the user and stored in the database. When viewing results we need to render this JSP to the client, evaluating all tags inside this JSP. ...

How to Pack/Encrypt/Unpack/Decrypt a bunch of files in Java?

I m essentially trying to do the following on a Java/JSP-driven web site: User supplies a password Password is used to build a strongly-encrypted archive file (zip, or anything else) containing a ...

JSP exception - class not found (tomcat)

I m setting up an existing application on a new Tomcat 5.5 server connecting to a Postgres database (running on Debian Lenny). When I access it I get a series of stack traces with the following root ...

ArrayList to Table in JSP

I have an ArrayList and i am trying to display it in a table ..... ArrayList rows = .... ..... <table cellspacing="1" cellpadding="4" border="3"> <tr> <TH>...

热门标签