There was a problem today when making a progress bar, I stored a counter in the session, when crawling to a data when the value of +1, and then the front desk every 3s to get a session of this value, but the problem comes out, under the FF, the value is normal, But under IE, anyway, is the previous value, only when the page is reopened to get the latest session value:
Here's the code for my probar.jsp:
<%@ page language= "java" import= "java.util.*" pageencoding= "utf-"%> <% String Path = Request.getcontextpath ();
String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/"; %> <script type= "Text/javascript" src= "<%=path%>/js/jquery.js" ></script> <script type= "text /javascript "src=" <%=path%>/js/jquery.progressbar.min.js "></script> <script type=" text/
JavaScript "> Function createxmlhttprequest () {var xmlHttp; if (window.
ActiveXObject) {xmlHttp = new ActiveXObject ("Microsoft.XMLHTTP");
else {xmlHttp = new XMLHttpRequest ();
return xmlHttp;
function Btn_click () {var xmlHttp;
XmlHttp = Createxmlhttprequest ();
Xmlhttp.onreadystatechange = processor;
Xmlhttp.open ("Get", "/jbbs/servlet/controlcrawl?method=getinforsize", true);
Xmlhttp.open ("POST", "/jbbs/servlet/controlcrawl?method=getinforsize", true);
Xmlhttp.send (NULL); function processor () {.......
}
} var action=setinterval ("Btn_click ();",); </script> <span> Crawl Progress:</span><br/> <div id= "container" ></div>
Later it was normal to change the get to post.
PS: About HTTP GET and post
HTTP defines different methods of interacting with the server, and the most basic methods are 4 kinds, namely get,post,put,delete. URL full name is a resource descriptor, we can think of: a URL address, which is used to describe a network of resources, and HTTP get,post,put,delete corresponding to this resource to check, change, increase, delete 4 operations. Here, you should have a rough idea, get is generally used to obtain/query resource information, and post is generally used to update resource information.
1. According to the HTTP specification, get is used for information acquisition and should be secure and idempotent.
(1). The so-called security means that the operation is used to obtain information rather than modify information. In other words, get requests should not generally have side effects. That is, it simply gets the resource information, like a database query, that does not modify, adds data, and does not affect the state of the resource.
* Note: The meaning of security here is simply to modify information.
(2). Idempotent means that multiple requests to the same URL should return the same result.
Idempotent (idempotent, idempotence) is a mathematical or computational concept that is common in abstract algebra.
Idempotent has several definitions:
For monocular operations, if an operation is the same as the result of doing this operation for a number of times in a range, then we call the Operation Idempotent. For example, the absolute value operation is an example, in the real number concentration, has abs (a) =abs (ABS (a)).
For binocular operations, it requires that when the two values of the participating operation are equivalent, if the result of the operation is equal to the two values of the participating operation, it is said that the power of the operation, such as the function of the maximum of two numbers, has the power in the real number concentration, that is, max (x,x) = x.
But in practical applications, the above 2 provisions are not so strict. Cite examples of other people's articles: for example, the front page of a news site is constantly updated. Although the second request returns a different batch of news, the operation is still considered safe and idempotent, as it always returns the current news. Fundamentally, if the goal is when a user opens a link, he can be sure that from his point of view there is no change in resources.
2. According to the HTTP specification, post represents a request that might modify a resource on a variable server.
Continue to cite the example above: or the news to the website, for example, readers of the news to publish their own comments should be implemented by post, because the site after the comments submitted resources are different, or the resources have been modified.
But in practice, many people do not follow the HTTP specification, which causes many reasons for this problem, such as:
1. Many people are greedy for convenience, update the resource with GET, because the post must be to form (form), this will be a bit of trouble.
2. The increase of resources, delete, change, check operation, in fact, can be completed through the get/post, do not need to use put and delete.
3. Another is that the early web MVC framework designers did not consciously view and design URLs as abstract resources, so a more serious problem is that the traditional Web MVC framework basically supports only get and post two HTTP methods, The put and delete methods are not supported.
* About MVC:
MVC is originally in the desktop program, m refers to the data model, v refers to the user interface, C is the controller. The purpose of using MVC is to separate the implementation code of M and v so that the same program can use different representations.
The above 3 points typically describe the old style (no strict adherence to the HTTP specification), and as the architecture progresses, there is now rest (Representationalstate Transfer), a new style of support for HTTP specifications, which is not much discussed here, and can be referenced in the RESTful Web Services.
Then look at the difference between get and post from the surface as above:
(1). First of all, "the data submitted by Get method can only be 1024 bytes", because get is to submit data through the URL, then the amount of data to be submitted can be directly related to the length of the URL. In fact, the URL does not have the problem of the upper limit of the parameters, the HTTP protocol specification does not limit the length of the URL. This restriction is restricted by specific browsers and servers. The Internet Explorer limit for URL length is 2083 bytes (2k+35). For other browsers, such as Netscape, Firefox, etc., there is no theoretical length limit, the limit depends on the operating system support. Note that this limit is the length of the entire URL, not just the length of your parameter value data.
(2). In theory, post is not the size limit, the HTTP protocol specification is not the size limit, said that "post data volume exists 80k/100k size limit" is inaccurate, post data is unrestricted, the limit is the processing of the server's processing capacity.
For ASP programs, the request object has a 100K data length limit when it processes each form field. But there is no such limit if you use Request.BinaryRead.
Extended by this, for IIS 6.0, Microsoft has increased its restrictions for security reasons.
We also need to note:
1). The maximum number of IIS 6.0 default ASP post data is 200KB, and each form field limit is 100KB.
2). The maximum size of the IIS 6.0 default upload file is 4MB.
3). The default maximum request header for IIS 6.0 is 16KB.
IIS 6.0 does not have these restrictions before.
So the above 80k,100k may be just the default value (Note: I haven't confirmed the parameters about IIS4 and IIS5), but I'm sure I can set it myself. Because each version of IIS does not have the same default values for these parameters, refer to the relevant IIS configuration documentation.
3. In ASP, the server gets get request parameter with Request.QueryString, gets the POST request parameter with Request.Form.
In the JSP, with Request.getparameter (\ "xxxx\") to get, although the JSP also has request.getquerystring () method, but the use of more trouble, such as: Pass a test.jsp?name= HYDDD&PASSWORD=HYDDD, with Request.getquerystring () is: name=hyddd&password=hyddd. In PHP, the data in get and post can be obtained separately with $_get and $_post, while $_request gets the data from the get and post two requests. It is noteworthy that the use of the JSP in the request and PHP use of $_request will have hidden dangers, this next time to write a summary of the article.
4.POST security is higher than get security.
Note: The security described here is not the same concept as the "security" mentioned above. The meaning of the above "security" is simply not to make data modifications, and here the meaning of security is the meaning of the real, for example: to submit data through get, user name and password will be clear on the URL, because (1) login page is likely to be cached by the browser, (2) Other people to view the history of the browser, Then others can get your account number and password, in addition, use get submit data may also cause Cross-site request forgery attack.
To sum up, get is a request to the server to ask for data, and post is a request to submit data to the server, in form (form), method defaults to "get", in essence, get and post only send mechanism is different, not one to take a hair!
The above is a small series with you share of Ajax access to the changing value of the session of the session and the difference between get and post in the HTTP protocol, I hope to be useful for you to learn more about the inconsistency of Ajax session, please continue to pay attention to this site.