Return-Path: Delivered-To: apmail-jakarta-struts-user-archive@apache.org Received: (qmail 19956 invoked from network); 28 Aug 2002 18:32:10 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 28 Aug 2002 18:32:10 -0000 Received: (qmail 10715 invoked by uid 97); 28 Aug 2002 18:32:26 -0000 Delivered-To: qmlist-jakarta-archive-struts-user@jakarta.apache.org Received: (qmail 10699 invoked by uid 97); 28 Aug 2002 18:32:25 -0000 Mailing-List: contact struts-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list struts-user@jakarta.apache.org Received: (qmail 10687 invoked by uid 98); 28 Aug 2002 18:32:25 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Date: Wed, 28 Aug 2002 11:31:49 -0700 (PDT) From: "Craig R. McClanahan" To: Struts Users Mailing List Subject: RE: JSP thread safety In-Reply-To: <8D966D6B75EB7F47AA300241BF2E1D0C011385C4@merc17.na.sas.com> Message-ID: <20020828112952.J32578-100000@icarus.apache.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: localhost 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N On Wed, 28 Aug 2002, Kevin A. Smith wrote: > Date: Wed, 28 Aug 2002 14:24:03 -0400 > From: Kevin A. Smith > Reply-To: Struts Users Mailing List > To: Struts Users Mailing List > Subject: RE: JSP thread safety > > It sounds like tag instances can be recycled after each request Close ... recycling in the same *page* is allowed, but that's primarily a performance optimization issue. > but not > shared between two requests executing at the same time. That is correct. Basically, a tag author doesn't need to worry about thread safety for its instance variables -- the container ensures that only one thread at a time will use any given instance. > In a way this > makes sense. Otherwise, it would be very difficult for tags to maintain > state during page processing (I'm thinking of parent/child tags here). > That's for sure :-). > --Kevin Craig > > -----Original Message----- > From: Galbraith, Paul [mailto:Paul.Galbraith@T4G.com] > Sent: Wednesday, August 28, 2002 2:21 PM > To: Struts Users Mailing List > Subject: RE: JSP thread safety > > > Ok, I think I understand for scriptlets: essentially, any JSP declarative tag is not thread-safe, but standard scriptlet desclarations are instance variables and thus threadsafe (I'm inferring). > > so, <%! int i; %> is avaialable to all requests, but <% int i; %> is not. > > I don't understand for tags, however. What is "action in the JSP" ([sic] from quote below)? I'm interested in how class variables in tag classes relate to HTTP requests...I can't sort that out from the quote below, sorry! They're instantiated for each request, I take it, and then reused within that request if more than one reference is made? > > Paul > > -----Original Message----- > From: James Higginbotham [mailto:jhigginbotham@betweenmarkets.com] > Sent: August 28, 2002 2:03 PM > To: Struts Users Mailing List > Subject: RE: JSP thread safety > > > Well, the JSP spec says it all - may want to take a look, or just write > a JSP page and have the compiler keep the generated code so you can look > at what it does. > > JSP 7.1.2.1: > > The JSP page implementation class instantiates a tag handler object, or > reuses > an existing tag handler object, for each action in the JSP page. The > handler object > is a Java object that implements the javax.servlet.jsp.tagext.Tag > interface. The > handler object is responsible for the interaction between the JSP page > and > additional server-side objects. > > > Thus, the JSP compiler will generally create a new instance to process > the tag in question. This is how nested tags may find their parents and > be able to lookup values within there. > > As for declared variables: > > > JSP.2.11.1 Declarations > Declarations are used to declare variables and methods in the scripting > language > used in a JSP page. A declaration should be a complete declarative > statement, or > sequence thereof, according to the syntax of the scripting language > specified. > Declarations do not produce any output into the current out stream. > Declarations are initialized when the JSP page is initialized and are > made > available to other declarations, scriptlets, and expressions. > > Examples > For example, the first declaration below declares an integer, global to > the > Scripting Elements 57 > page. The second declaration does the same and initializes it to zero. > This type > of initialization should be done with care in the presence of multiple > requests > on the page. The third declaration declares a method global to the page. > <%! int i; %> > <%! int i = 0; %> > <%! public String f(int i) { if (i<3) return("..."); ... } %> > Syntax > <%! declaration(s) %> > > > > As for anything else generated for a JSP tag (including custom tags), > its declared within the body of the generated method by the JSP compiler > and thus they go on the stack for the thread, rather than the heap. > > James > > > -----Original Message----- > > From: Kevin A. Smith [mailto:KevinA.Smith@sas.com] > > Sent: Wednesday, August 28, 2002 12:54 PM > > To: Struts Users Mailing List > > Subject: RE: JSP thread safety > > > > > > Not sure about the taglib class variables (but I'd really > > like the answer to that one also). > > > > With respect to JSP thread safety, my understanding was that > > any variables declared in the page were only in scope during > > the execution of the page, much like variables in method > > scope. If the pages in question are also declaring private > > member variables or static variables, well that's another > > story entirely. > > > > --Kevin > > > > -----Original Message----- > > From: Galbraith, Paul [mailto:Paul.Galbraith@T4G.com] > > Sent: Wednesday, August 28, 2002 1:34 PM > > To: struts-user@jakarta.apache.org > > Subject: JSP thread safety > > > > > > Can someone clear up basics of JSP thread safety for me? Can > > I declare variables in scriptlets and maintain thread safety? > > Also, what about custom tags. They declare class variables, > > which makes me nervous...does the container ensure thread > > safety for custom tags (assuming they release properly in the > > release() method)? Cheers, > > > > Paul > > > > -- > > To unsubscribe, e-mail: > > unsubscribe@jakarta.apache.org> > > For > > additional commands, > > e-mail: > > > > > > -- > To unsubscribe, e-mail: > For additional commands, e-mail: > > > -- > To unsubscribe, e-mail: > For additional commands, e-mail: > > > -- > To unsubscribe, e-mail: > For additional commands, e-mail: > > -- To unsubscribe, e-mail: For additional commands, e-mail: