On the homepage of J2EE development, choose index.htm or index. jsp.

Source: Internet
Author: User

On the homepage of J2EE development, choose index.htm or index. jsp.

During J2EE development, the home page can usually be index.htm, index.html, index. jsp, default.htm, default.html, and default. jsp. Do you know which one to use?

In the past, I thought it was okay. So I have index.htm, a static html page, which contains a jump,
<Meta http-equiv = "refresh" content = "0; url = xxx">
Go to a dynamic page, like a http://www.test.com/mysystem/show_home

Recent tests have found that this approach is problematic. The main reason is that you need to use filter to determine whether you have logged on to this page, and then jump to "logged on Homepage" and "not logged on Homepage ". This requires that the page cannot be cached by the browser at http://www.test.com/mysystem /.

In tomcat, use index.htm and filter to force the browser not to cache the page. This will cause Tomcat to generate the HTTP Response Header as follows:
HTTP/1.1 200 OK
Server: APACHE-Coyote/1.1
Expires:-1
Cache-control: No-cache, no-store, Private, Max-age = 0, S-maxage = 0, must-revalidate
Pragma: No-Cache
Last-modified: Fri, 15 Oct 2010 01:31:59 GMT
Accept-ranges: bytes
Etag: W/"680-1287106319011"
Content-Type: text/html
Content-Length: 680
Date: Mon, 08 Nov 2010 07:53:40 GMT

The etag is automatically added for Tomcat, and the time in last-modified is the time of the index.htm file.
Access the http://www.test.com/mysystem/ again, the client Firefox will generate the HTTP request header:
If-modified-since current time.
At this time, the client will be directly notified of "Page not modified" by comparing the file time (last-modified-since and index.htm) of IF-modified-since on the server ". In this case, the browser retrieves the "not logged on Homepage" from the local cache, resulting in confusion between "logged on Homepage" and "not logged on Homepage" on the client.

The cause is that "logged on Homepage" and "not logged on Homepage" use the same web site. When Tomcat processes index.htm, excessive etag and incorrect last-modified are generated.
There are multiple solutions. The simplest way is to change index.htm to index. jsp.
Furthermore, to avoid the problem, we recommend that you change all the HTML files directly accessed in the J2EE project to the suffix JSP.

In addition, it seems that you need
<Meta http-equiv = "refresh" content = "0; url = xxx">
Change
<Script language = "JavaScript" type = "text/JavaScript">
Document. Location = "XXX ";
</SCRIPT>

Because Meta Refresh is cached in different browsers in different ways. Therefore, we recommend that you avoid using Meta Refresh.

From http://www.cnblogs.com/jacklondon

Related Article

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.