JSP container failure under several conditions and the session should

2010-05-27  来源:本站原创  分类:Web  人气:207 

JSP container failure under several conditions and the session yesterday a colleague spoke of a OA project, failure is always there session, I summarized several cases have faced for his consideration:

1. Long time the browser requests to the back, over the web.xml, <session-timeout> specified time.
Response: this is the application expected, the background check to the session after the failure to guide the user to the login screen.

2.cookie exceed the limit, resulting in jsessionId lost, leading to session failure
Default settings in the browser, session mechanism is stored in the cookie in the jsessionId, modifications will become stateless http connection with the state of the browser's cookie, but most realize the cookie number and length restrictions, refer to the following article
http://www.nczonline.net/blog/2008/05/17/browser-cookie-restrictions/
When the cookie exceed the limit, jsessionId as an ordinary cookie to be "squeezed" out to jsessionId as Jietouanhao the session useless.
Use cookie save large amounts of data in the foreground is unwise to replace the method is to use js as a data carrier, of course, need to address how the js shared problems between pages.
I have encountered in the implementation of the project specific examples are:
Provide the advantage of using the cookie stored Ext layout customization, that is: Ext.state.Manager.setProvider (new Ext.state.CookieProvider ());
Ext customize the interface package to the cookie store, through firebug observation, once the drag on the grid, it will add a name ys-ext-comp-XXX is about the size of the cookie for the 2k
oh my god! use Ext's friends must watch out!

3.apache redirected to tomcat lead to session failure
This may only met a few people, I'm one of them. CMS in the development of a specific time, use the apache reverse caching mechanism (see the car, Mr. Tung article)
Will encounter 404 error http requests to tomcat to handle.
As the website content editors back side of the input under jsp container contents, use the reverse side of the preview page caching mechanism.
The results showed that only conduct a preview, session becomes ineffective.
Tracking the process found that the results apache redirects, no forwarding to tomcat jsessionId this cookie.

My solution: the jsessionId cookie from the default memory read, write disk cookie, Cookies.setAge ('JSESSIONID', 1);
Laws related to the operation of the cookie function as follows:

var Cookies = {};
Cookies.setAge = function(name,days){
    var jck= Cookies.get(name);
    var exp  = new Date();
    exp.setTime(exp.getTime() + days*24*60*60*1000);
    Cookies.set(name,jck,exp);
};
Cookies.set = function(name, value){
     var argv = arguments;
     var argc = arguments.length;
     var expires = (argc > 2) ? argv[2] : null;
     var path = (argc > 3) ? argv[3] : '/';
     var domain = (argc > 4) ? argv[4] : null;
     var secure = (argc > 5) ? argv[5] : false;
     document.cookie = name + "=" + escape (value) +
       ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
       ((path == null) ? "" : ("; path=" + path)) +
       ((domain == null) ? "" : ("; domain=" + domain)) +
       ((secure == true) ? "; secure" : "");
};

Cookies.get = function(name){
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        var j = 0;
        while(i < clen){
                j = i + alen;
                if (document.cookie.substring(i, j) == arg)
                        return Cookies.getCookieVal(j);
                i = document.cookie.indexOf(" ", i) + 1;
                if(i == 0)
                        break;
        }
        return null;
};

Cookies.clear = function(name) {
  if(Cookies.get(name)){
    document.cookie = name + "=" +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
};

Cookies.getCookieVal = function(offset){
   var endstr = document.cookie.indexOf(";", offset);
   if(endstr == -1){
       endstr = document.cookie.length;
   }
   return unescape(document.cookie.substring(offset, endstr));
};
相关文章
  • JSP container failure under several conditions and the session should 2010-05-27

    JSP container failure under several conditions and the session yesterday a colleague spoke of a OA project, failure is always there session, I summarized several cases have faced for his consideration: 1. Long time the browser requests to the back, o

  • Apache Tomcat 5.5 Servlet / JSP container how to prepare Cluster / Session Replication 2010-06-18

    Source text: http://www.jaxmao.org/tomcat-docs/cluster-howto.html Apache Tomcat 5.5 Servlet / JSP container How to prepare the cluster / Session Replication Getting Started To the Tomcat 5.5 container for session replication, you must complete the fo

  • Apache Tomcat 5.5 Servlet / JSP container 2009-10-15

    How the preparation of the cluster / Session replication print-friendly version Load Balancing section. Note: Remember your session state is tracked by a cookie, so you see the URL from the outside must be the same, otherwise a new session will be ge

  • Check each application server oracle database session occupancy conditions and v $ session view 2010-09-16

    Check each application server oracle database session occupation situation select machine, count (*) c from v $ session group by machine order by c desc; Check the machine under the machine name given to all sessions select t.STATE, t. * from v $ ses

  • url of the jsessionid to explain - -- 2010-04-09

    url of the jsessionid to explain - -- (1) This is an insurance policy because the Session default Cookie support is required, but some customers Cookie browser is closed at this time of need in the URL specified in the server session ID (2) Link 1: w

  • url of the jsessionid explanation (change) 2010-04-26

    (1) This is an insurance policy because the Session default Cookie support is required, but some customers Cookie browser is closed at this time of need specified in the URL on the server session ID, which is 5F4771183629C9834F8382E23BE13C4C Using a

  • JSP include directive and include in the distinction between acts 2010-09-05

    We all know that include the jsp in two forms, namely, <% @ include file = ""%> <Jsp: include page = "" flush = "true" /> The former is a command element, which is the behavior of elements. Specifically where they

  • Jsp / Servlet review notes ----- JSP based on Chapter 6 2010-10-26

    6.1 JSP Introduction 6.1.1 JSP needs and benefits Separation generated content and said: Although the essence of JSP Servlet, but compared with the Servlet, content generation and that separation is an advantage of JSP, Servlet can not solve this. Se

  • JSP dynamic web page programming (I) 2010-03-29

    JSP (JavaServer Pages): JSP pages from the traditional form of web pages is HTML file to add Java program fragment (Scriptlet), and JSP tags. Servlet / JSP container received a request issued by the client, the first implementation of the program in

  • jsp custom tag development 2010-03-29

    Tag handler Before you create a custom label, need to create a tag handler. Tag handler is an implementation of the custom label operated Java objects. When using a custom tag to import a tag library - that is, a set of labels / Tag handler right. Th

  • Chapter 8, JavaServer Pages (JSP) 2010-04-25

    Chapter 8, JavaServer Pages (JSP) 8.1 JSP and Servlet relationship: JSP is a Servlet extension of a higher level, through the JSP allows developers to plain Java code embedded into HTML pages, JSP files end Web server's Web container through compiled

  • JSP import the two methods (transfer) 2009-05-21

    We all know that include the jsp in two forms, namely, <% @ Include file = ""%> <jsp:include page=" "flush="true"/> The former is a command element, which is the behavioral elements. Specifically where they will u

  • Servlet and JSP compilation manual 2010-03-27

    Integrated development environment for developers to use In work for the user to bring a great convenience, but also some "hazy sense" - which shields the user of the operation flow and a number of specific details, developers feel the developme

  • JSP Study Notes 2 - The page compiler directive directive 2010-04-07

    JSP directive will be converted to the corresponding JSP engine's Java code, but these Java code does not directly produce any visible Shuchu but to inform the JSP engine Ruhe Processing JSP pages, Servlet classes Huoshi how Sheng Cheng. JSP directiv

  • Study Notes 4-JSP JSP standard action of <jsp:forward> and <jsp:include> 2010-04-07

    JSP compiler JSP container directive is to automatically take action; and JSP's operating instructions is a programmer control the operation of the JSP page is used. 1, page Jump: <jsp:forward> action (not recommended) forward movement in the interf

  • JSP include in usage and differences between the two 2010-04-18

    We all know that include the jsp in two forms, namely <%@ include file=" "%> <jsp:include page=" " flush="true"/> The former is a command element, which is the behavior of elements. Specifically where they will us

  • JSP custom tag (transfer) 2010-04-19

    1, JSP custom tag Description tag is an XML element, the tag can get simple JSP pages and easy to maintain, you can easily achieve the same JSP file to support multiple languages. As the label is the XML element, its name and attributes are case-sens

  • Inside tomcat (1 )------- container you know what? 2010-06-19

    Tomcat container recent study, to write a series of articles to share with everyone. This article first as a primer, do not involve any underlying implementation of tomcat. We know the servlet specification: Provides the life cycle of servlet: init->

  • JSP four types of session tracking technology 2010-06-22

    Reprint: Cookie: the server response in a first pass to the browser name / value pairs. Save time by the browser cookie expiration time attribute to specify. When a browser sends a request to a server, it will check the saved cookie, and first includ

  • JSP built objects and methods of understanding 2010-06-25

    jsp built-object transfer] [2008-08-09 09:47 ① out - javax.servlet.jsp.jspWriter out object is used to output to web pages. Method: 1. Void clear (); Clear the contents of the output buffer, but does not output to the client. 2. Void clearBuffer ();