Custom tag as performance hits.

          Hi All,
          I want to know if there is a correlation between the number of custom tags used in
          a JSP page and the page's performance.
          Is there a guideline/study which indicates (or otherwise) that increasing the number
          of custom tags decreases the loading (rendering) time of the JSP page. I understand
          that more tags mean more jsp-compilation time but I am interested in runtime performance.
          Thanks,
          Anu
          

I want to know if there is a correlation between the number of custom tags          used in
          > a JSP page and the page's performance.
          >
          > Is there a guideline/study which indicates (or otherwise) that increasing
          the number
          > of custom tags decreases the loading (rendering) time of the JSP page. I
          understand
          > that more tags mean more jsp-compilation time but I am interested in
          runtime performance.
          Each additional tag adds some runtime overhead. The overhead is primarily
          determined by the quality of the tag implementation. I'd rather have 1000
          well written tags than 1 poorly written one ;-) ... e.g. if you are doing
          JDBC calls from a tag, then you will probably get into trouble in a hurry.
          Peace,
          Cameron Purdy
          Tangosol, Inc.
          Clustering Weblogic? You're either using Coherence, or you should be!
          Download a Tangosol Coherence eval today at http://www.tangosol.com/
          "Anu Agrawal" <[email protected]> wrote in message
          news:3cd821c0$[email protected]..
          >
          

Similar Messages

  • Custom Tag Implementation seems inefficient

    I've been playing around a bit (alright, so maybe not all that much)
              with custom tags, and it seems like the actual implementation of custom
              tags (tag handler object(s) per tag) is much more resource-intensive
              than would be justified. With Weblogic 5.1 SP6, has anyone had the
              opportunity to compare performance of a typical JSP page w/ and w/out
              custom tags?
              My first impression of custom tags was that you could define tags
              and behaviors that the JSP compiler would then compile into your JSP
              class; there would be no performance hit during page execution. The Java
              code used to write these tags would either be included inline in the JSP
              page code, or else act essentially as static (threadsafe) classes into
              which threads executing JSP pages would call into. This approach means
              less resources consumed and less setup/teardown time in exchange for
              fatter JSPC'd code.
              Instead (and correct me if I am wrong), it appears that each
              distinct custom tag has a pool of instantiated handler objects lying
              around in memory, and each time a custom tag is used, there is a
              little performance hit in the setup & teardown of each handler object's
              pageContext, etc...
              Now admittedly, as another poster (I believe Mr. Purdy) pointed out,
              a "little" ain't all that much... unless there are thousands of those
              "little" hits.
              Moreover, I don't see much benefit in having instantiated objects do
              the heavy lifting. I'd rather have my auto-compiled JSP classes be a
              little more bloated than suffer any performance hit. (I do, however,
              like the fact that custom tags allows for cleaner JSP code, not to
              mention makes for a cleaner break between the creative and coding work.)
              For those of you who've had more extensive experience with custom
              tags, am I missing the target? Is the performance hit negligible for
              heavily-used or complex pages? And/or is the performance hit outweighed
              by code and development cleanliness?
              Thanks for any input.
              Jack
              

    Hi Sri
              Looks like you've found an inefficiency in WebLogic's JSP compiler - it
              should be reusing tag instances within the same page. BEA should fix this
              hopefully.
              > So even if a page has 4 tags and 100 users, we have 400 objects just
              > because we use tags.
              Sure, assuming you have 100 concurrent users (and 100 threads in the servlet
              engine). Though creating 400 objects is not a big deal in Java; most non
              trivial Java applications / services create millions of objects.
              Its also worth noting that having a seperate object instance per tag per
              calling thread means that you don't have to do any synchronisation in the
              custom tag (since you're guarenteed to be called by one thread only) so you
              get maximum thread throughput at the expense of some object allocation.
              If you really don't like the idea of creating a few java objects per request
              you could use XSLT to post process JSP files to replace tag occurencies with
              Java scriptlets - though I'm not sure the extra complexity and restrictions
              that this mechanism imposes is worth it at all. Custom tags rock! ;-)
              J.
              James Strachan
              =============
              email: [email protected]
              web: http://www.metastuff.com
              "Sri" <[email protected]> wrote in message
              news:[email protected]...
              > This post had some interesting aspects about custom tags that contradict
              > what I see in the generated java code by the JSP container. I am using
              > weblogic 5.1 sp6 and I have a jsp file that uses a custom tag "xyz:for" a
              > couple of times. the tags are not nested.
              > The java code indicates that two separate instances for the "xyz:for" tag
              > were created.
              >
              > try
              >
              > calicothunder_presentation_tags_ForTag_0 = new
              > calico.thunder.presentation.tags.ForTag();
              >
              > ..............
              >
              > } finally
              >
              > if (_calico_thunder_presentation_tags_ForTag_0 != null)
              > calicothunder_presentation_tags_ForTag_0.release();
              > }
              >
              > Further down
              >
              > try {
              > calicothunder_presentation_tags_ForTag_1 = new
              > calico.thunder.presentation.tags.ForTag();
              > ...............
              >
              > } finally
              >
              > if (_calico_thunder_presentation_tags_ForTag_1 != null)
              > calicothunder_presentation_tags_ForTag_1.release();
              > }
              >
              > The code is creating two different objects for every request. It is not
              > reusing the same object.
              > The release is just cleaning up the current instance, which may be garbage
              > collected at some later stage.
              > So even if a page has 4 tags and 100 users, we have 400 objects just
              > because we use tags.
              >
              > Just trying to understand this better..
              > thanks - Sri
              >
              >
              >
              > "James Strachan" <[email protected]> wrote in message
              > news:[email protected]...
              > > Hi Jack
              > >
              > > I think you're right to be concerned and it is a valid concern.
              > >
              > > In the scheme of things in my experience the cost of using custom tags
              is
              > > quite minimal. Tag instances are reused on the same page so if I have
              > > several non-nested <foo:bar> tags on a page the single FooBarTag
              instance
              > > will be reused for each tag occurance.
              > >
              > > Consider other Java code, say, string concatenation. Consider the
              > following
              > > expression.
              > >
              > > String c = a + b;
              > >
              > > Fairly minimal code you might think. However this line actually involves
              > the
              > > creation of a StringBuffer instance, the call of 2 methods and the
              > creation
              > > of a second String object instance (never mind the internal char[]
              object
              > > instance that is created inside the new Strings constructor).
              > >
              > > A typical use of a custom tag involves one object construction, N
              > > setProperty() method calls (one for each attribute of the tag) and the
              > > startTag / endTag method calls.
              > >
              > > So on balance I'd say the custom tags mechanism is quite small and
              > > efficient.
              > >
              > > Though note that if you use large numbers (say hundreds) of different
              > kinds
              > > of tags then you'll have a much greater object allocation overhead.
              > >
              > > --
              > > J.
              > >
              > > James Strachan
              > > =============
              > > email: [email protected]
              > > web: http://www.metastuff.com
              > > "Jack Lin" <[email protected]> wrote in message
              > > news:[email protected]...
              > > > I've been playing around a bit (alright, so maybe not all that much)
              > > > with custom tags, and it seems like the actual implementation of
              custom
              > > > tags (tag handler object(s) per tag) is much more resource-intensive
              > > > than would be justified. With Weblogic 5.1 SP6, has anyone had the
              > > > opportunity to compare performance of a typical JSP page w/ and w/out
              > > > custom tags?
              > > >
              > > > My first impression of custom tags was that you could define tags
              > > > and behaviors that the JSP compiler would then compile into your JSP
              > > > class; there would be no performance hit during page execution. The
              Java
              > > > code used to write these tags would either be included inline in the
              JSP
              > > > page code, or else act essentially as static (threadsafe) classes into
              > > > which threads executing JSP pages would call into. This approach means
              > > > less resources consumed and less setup/teardown time in exchange for
              > > > fatter JSPC'd code.
              > > > Instead (and correct me if I am wrong), it appears that each
              > > > distinct custom tag has a pool of instantiated handler objects lying
              > > > around in memory, and each time a custom tag is used, there is a
              > > > little performance hit in the setup & teardown of each handler
              object's
              > > > pageContext, etc...
              > > > Now admittedly, as another poster (I believe Mr. Purdy) pointed
              out,
              > > > a "little" ain't all that much... unless there are thousands of those
              > > > "little" hits.
              > > > Moreover, I don't see much benefit in having instantiated objects
              do
              > > > the heavy lifting. I'd rather have my auto-compiled JSP classes be a
              > > > little more bloated than suffer any performance hit. (I do, however,
              > > > like the fact that custom tags allows for cleaner JSP code, not to
              > > > mention makes for a cleaner break between the creative and coding
              work.)
              > > >
              > > > For those of you who've had more extensive experience with custom
              > > > tags, am I missing the target? Is the performance hit negligible for
              > > > heavily-used or complex pages? And/or is the performance hit
              outweighed
              > > > by code and development cleanliness?
              > > >
              > > > Thanks for any input.
              > > > Jack
              > > >
              > > >
              > >
              > >
              >
              >
              

  • How to access variables passed in custom tag body

    I am developing custom tags in my application. I need to pass some variables from the .jsp file into tag file. I want these to be passed as body of the tag rather than as tag parameter. It seems the correct syntax for this is:
    <myTags:display> someVariable </myTags:display>
    Question 1: Can I not use this as: <myTags:display someVariable /> Since this tag will be used at many places in the jsp, I dont want to write myTags:display twice for every usage.
    Question 2:
    I want to call the tags from main.jsp like:
    <% String var1 = "Display Me Please"; %>
    <myTags:display var1 />I want the tag file to do some processing on the value stored in var1. I've written the following code in tag file, display.tag:
    <jsp:doBody var="theBody" />
    <% Object obj = (Object) request.getAttribute ("theBody"); %>This code snippet gives me access to obj which has the value "var1". Now how do I access the value that is contained in "var1".
    Edited by: coolkomal on Jun 3, 2009 7:45 AM

    coolkomal wrote:
    I am developing custom tags in my application. I need to pass some variables from the .jsp file into tag file. I want these to be passed as body of the tag rather than as tag parameter. It seems the correct syntax for this is:
    <myTags:display> someVariable </myTags:display>
    Question 1: Can I not use this as: <myTags:display someVariable /> Since this tag will be used at many places in the jsp, I dont want to write myTags:display twice for every usage.
    <myTags:display var="<%=someVariable>"/> is a valid syntax for performing respective action of that variable. You can also use EL to pass the variable ${someVariable} provided the custom tag provide support for EL.
    >
    Question 2:
    I want to call the tags from main.jsp like:
    <% String var1 = "Display Me Please"; %>
    <myTags:display var1 />
    Just ensure that you declare all the related variables in Main.jsp and statically include Main.jsp in your jsp such that you do the checking
    [http://java.sun.com/products/jsp/tags/11/syntaxref117.html]
    >
    I want the tag file to do some processing on the value stored in var1. I've written the following code in tag file, display.tag:
    <jsp:doBody var="theBody" />
    <% Object obj = (Object) request.getAttribute ("theBody"); %>This code snippet gives me access to obj which has the value "var1". Now how do I access the value that is contained in "var1".Can be done provided you code it the right way. Start learning basics of how to create custom taglibraries to gain more knowledge on how things can be managed.
    [http://java.sun.com/javaee/5/docs/tutorial/doc/bnalj.html]

  • SAP CRM custom tags in MS Word

    Hi
    When working with MS Word templates functionality in Attachments assignment block and generating a word document pressing "with template" button we can use BADI CRM_OFFICE_TEMPLATE_BADI to transfer custom tags inside the template. But is it possible to use those custom tags transferred in formulas inside the template? I mean the formula "If" from the menu Insert->Quick parts->Field->If ? Otherwise, is there any solution to use the tags in any formulas inside the template?
    Regards,
    Aliaksei

    Actually it's based on past productive experience of using complicated word templates that I'm basing my answer.  My collegaue who had calcuated field requirements did not use formulas in our more complex word templates and instead we performed the calculation in CRM instead.  Oh BTW, I'm actually not an SAP Employee by any means, but a customer of SAP instead.  We had been using word templates productively on our 7.0 installation for at least four years.  When we had to migrate the work to EHP1 system with the new content controls, there were many bugs in the standard delivered solution include problems when macros existed in the document that were released by notes by SAP.
    Take care,
    Stephen

  • Custom tag - setProperties() not called

    Hi all,
    I've created my first custom tag with it's own component class, Tag Class, Renderer and TLD. However, when the JSP first loads, the encode() method fails in trying to get the attribute values from the attribute Map - the Map is empty. Upon further debugging I can see that the Tag class is called and the setter methods are called for each attribute but the setProperties() method is never called before release(), so the attributes are never stored in the UIComponent's attribute Map.
    Anybody know what I'm doing wrong?
    Some code:
    Tag Class...
    public class ListShuttleTag extends UIComponentTag
    public void setProperites(UIComponent component)
      super.setProperties(component);
      ComponentTagHelper.setString(component, "sourceValue", sourceValue);
      ComponentTagHelper.setString(component, "targetValue", targetValue);
      ComponentTagHelper.setInteger(component, "size", size);
      ComponentTagHelper.setInteger(component, "targetListWidth", targetListWidth);
      ComponentTagHelper.setInteger(component, "sourceListWidth", sourceListWidth);
      ComponentTagHelper.setString(component, "sourceCaption", sourceCaption);
      ComponentTagHelper.setString(component, "targetCaption", targetCaption);
    ...TLD...
      <taglib>
        <tlib-version>1.1</tlib-version>
        <jsp-version>2.1</jsp-version>
        <tag>
          <name>listShuttle</name>
          <tag-class>com.katun.jsf.tag.ListShuttleTag</tag-class>
          <description>A listShuttle allows the moving of items from one listBox to another</description>
          <!-- General component attributes -->
          <attribute>
            <name>binding</name>
            <description>
                 A binding that points to a bean property
            </description>     
          </attribute>
          <attribute>
            <name>id</name>
            <description>The client id of this component</description>     
          </attribute>
          <attribute>
            <name>rendered</name>
            <description>Is this component rendered?</description>     
          </attribute>
          <attribute>
            <name>disabled</name>
            <description>Is this component disabled?</description>     
          </attribute>
          <attribute>
            <name>required</name>
            <description>Is this component required?</description>     
          </attribute>
          <!-- listShuttle specific attributes -->
          <attribute>
            <name>sourceValue</name>
            <required>true</required>
            <description>A binding for the items in the source list</description>
          </attribute>
          <attribute>
            <name>targetValue</name>
            <description>A binding for the items in the target list</description>
          </attribute>
          <attribute>
            <name>size</name>
            <description>Defines the number of items visible in each list</description>
          </attribute>
          <attribute>
            <name>sourceListWidth</name>
            <description>Width of the source list</description>
          </attribute>
          <attribute>
            <name>targetListWidth</name>
            <description>Width of the target list</description>
          </attribute>
          <attribute>
            <name>sourceCaption</name>
            <description>Label displayed above the source list</description>
          </attribute>
          <attribute>
            <name>targetCaption</name>
            <description>Label displayed above the target list</description>
          </attribute>
        </tag>
    ...

    Gotcha........
    First, this is what the jsp spec has to say in sec 1.14.1
    When using scriptlet expressions, the expression must
    appear by itself (multiple expressions, and mixing of expressions and string
    constants are not permitted). Multiple operations must be performed within the
    expression.Simple, isnt it ? All you have to is evaluate the expression as a whole.
    <form:toolbaritem id="icon_cancelar" action="<%="javascript:listingAction('" + request.getContextPath() + "/logout.do;')"%>" icon<%= request.getContextPath() + " /images/toolbar/Cancelar_32.gif " %>"/>cheers,
    ram.

  • Custom Tag Attribute not correctly rendered

    Hello,
    I made a custom tag and I want the engine to parse dynamic scripts and evaluate them.
    I call the tag like this :
        <form:toolbaritem id="icon_cancelar" action="javascript:listingAction('<%= request.getContextPath() %>/logout.do');" icon="<%= request.getContextPath() %>/images/toolbar/Cancelar_32.gif"/>The icon and action attributes are declared in the tld like so :
              <attribute>
                   <name>action</name>
                   <required>true</required>
                   <rtexprvalue>true</rtexprvalue>
              </attribute>
              <attribute>
                   <name>icon</name>
                   <required>true</required>
                   <rtexprvalue>true</rtexprvalue>
              </attribute>However, the tag is not working with the evaluated expression, receiving "<%= request.getContextPath() %>" instead.
    Any help would be very welcome :) thank you
    Eamerial

    Gotcha........
    First, this is what the jsp spec has to say in sec 1.14.1
    When using scriptlet expressions, the expression must
    appear by itself (multiple expressions, and mixing of expressions and string
    constants are not permitted). Multiple operations must be performed within the
    expression.Simple, isnt it ? All you have to is evaluate the expression as a whole.
    <form:toolbaritem id="icon_cancelar" action="<%="javascript:listingAction('" + request.getContextPath() + "/logout.do;')"%>" icon<%= request.getContextPath() + " /images/toolbar/Cancelar_32.gif " %>"/>cheers,
    ram.

  • Parsing EL expression in custom tag 10.1.3.4

    Hello all,
    I have a custom tag that extends CoreOutputTextTag. This tag needs to resolve the El expression passed in from the value attribute and perform an operation with it. Since I this tag needs to work with adf 10.1.3.4, the jsp level is 1.2 and does not support container parsing of EL expression directly in the page ($).
    I have tried a couple approaches but both of them result in just the same EL expression I pass in being returned to me. Anyone have an idea of the proper way to resolve an EL expression within a custom tag?
    Thanks in advance,
    - Joe
    public class CoreOutputTextTag extends oracle.adfinternal.view.faces.taglib.core.output.CoreOutputTextTag {
        private String groupId;
        private String groupCode;
        private String value;
        public void setValue(String value) {
            this.value = value;
            super.setValue(value);
        public int doStartTag() throws JspException {
            super.doStartTag();
            UIComponent uiComponent = this.getComponentInstance();
            if (uiComponent instanceof CoreOutputText) {
                CoreOutputText coreOutputTextComponent =
                    (CoreOutputText)uiComponent;
                if (coreOutputTextComponent.getValue() == null) {
                    String codeValue =
                        (String)ExpressionEvaluatorManager.evaluate("value", value,
                                                                    java.lang.String.class,
                                                                    this,
                                                                    pageContext); // the page context
                    try {
                        ExpressionEvaluator expressionEvaluator =
                            pageContext.getExpressionEvaluator();
                        codeValue =
                                (String)expressionEvaluator.evaluate(value, java.lang.String.class,
                                                                     pageContext.getVariableResolver(),
                                                                     null);
                    } catch (ELException elex) {
                    SystemSettingRow row =
                        SystemSettings.getSystemSettings(groupId, groupCode, null,
                                                         value);
                    if (row != null)
                        coreOutputTextComponent.setValue(row.getShortDesc());
            return TagSupport.SKIP_BODY;
        public void setGroupId(String groupId) {
            this.groupId = groupId;
        public String getGroupId() {
            return groupId;
        public void setGroupCode(String groupCode) {
            this.groupCode = groupCode;
        public String getGroupCode() {
            return groupCode;
    <tag>
      <name>coreOutputText</name>
      <tag-class>od.adf.ics.ui.taglib.CoreOutputTextTag</tag-class>
      <body-content>empty</body-content>
      <attribute>
       <name>groupId</name>
       <required>true</required>
      </attribute>
      <attribute>
       <name>groupCode</name>
       <required>true</required>
      </attribute>
      <attribute>
       <name>id</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>truncateAt</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>description</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>escape</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>shortDesc</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>partialTriggers</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>onclick</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>ondblclick</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>onmousedown</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>onmouseup</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>onmouseover</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>onmousemove</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>onmouseout</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>onkeypress</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>onkeydown</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>onkeyup</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>styleClass</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>inlineStyle</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>value</name>
       <rtexprvalue>true</rtexprvalue>
      </attribute>
      <attribute>
       <name>converter</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>rendered</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>binding</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>attributeChangeListener</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
    </tag>

    I also would like to know how to accomplish this. I have a similar requirement and need to set the "disable" attribute on a commandbutton and requires an el statement that calls a methodAction defined on the pageDef.
    I followed the great instructions over on this thread:
    ADF FACES:Creating custom component on top of adf
    on how to create custom adf tags for JDeveloper 10.1.3.4.
    many thanks!
    Wes
    Edited by: Wes Fang on Sep 16, 2010 5:39 AM

  • How to clear the custom tags in the phonebook?

    some time create a label on the agenda of the phone contacts, your name is "profile", but now I want to delete because it is no longer useful, but not how to delete this custom tag.
    I want to know how can i delete this custom tag?

    Hi,
    We need to use FREE statement.
    please do this way:
    For
    form exit_program .
      call method cc1->free.
      call method cc2->free.
      call method cc3->free.
      call method cc4->free.
      call method cl_gui_cfw=>flush.
      if sy-subrc <> 0.
        call function 'POPUP_TO_INFORM'
          exporting
            titel = lv_repid
            txt1  = 'Error in Flush'(500)
            txt2  = sy-subrc.
      endif.
    endform.                    " exit_program
    module user_command_0100 input.
      case sy-ucomm.
        when 'BACK'.
          perform exit_program.
          set screen '0'.
        when 'EXIT' or 'CANC'.
          perform exit_program.
          leave program.
      endcase.
    endmodule.                 " USER_COMMAND_0100  INPUT
    thanx.

  • Can i use Custom Tags for Database retrieval (as per MVC pattern)?

    In our project we are dealing with database, and i've used the Cutom Tags for database retrieval (as per the Article from Mr Faisal Khan) and it is working fine. But i have a doubt if it affects the performance in any way . I wanted to know if its recommendable to use Custom Tags for the DB retrieval as per MVC Pattern or shall i create a intermediate bean and then call the bean in custom tag.
    Thanks
    Prakash

    Putting database code in your JSPs certainly couples your view to the database. That's usually not good.
    If it's a simple app, it might be justified.
    When you start having lots of pages and complex business logic it becomes less attractive. - MOD

  • Re: Using ScopeCache custom tag

    Hi, I am quite new to ColdFusion and I have a calendar that
    is quite slow due to the cfloops it uses to build the calendar. As
    the page does not change very often I wanted to use Raymond
    Camden's ScopeCache custom tag. However, for some reason the custom
    tag was not getting picked up from the custom tag folder on the
    server. I have successfully used components so have tried to
    convert the custom tag to a component but get the following error
    message:
    Routines cannot be declared more than once.
    The routine scope_Cache has been declared twice in the same
    file.
    This is the component:
    <!---
    Name : scopeCache
    Author : Raymond Camden ([email protected])
    Created : December 12, 2002
    Last Updated : November 6, 2003
    History : Allow for clearAll (rkc 11/6/03)
    : Added dependancies, timeout, other misc changes (rkc
    1/8/04)
    Purpose : Allows you to cache content in various scopes.
    Documentation:
    This tag allows you to cache content and data in various RAM
    based scopes.
    The tag takes the following attributes:
    name/cachename: The name of the data. (required)
    scope: The scope where cached data will reside. Must be
    either session,
    application, or server. (required)
    timeout: When the cache will timeout. By default, the year
    3999 (i.e., never).
    Value must be either a date/time stamp or a number
    representing the
    number of seconds until the timeout is reached. (optional)
    dependancies: This allows you to mark other cache items as
    dependant on this item.
    When this item is cleared or timesout, any child will also
    be cleared.
    Also, any children of those children will also be cleared.
    (optional)
    clear: If passed and if true, will clear out the cached
    item. Note that
    this option will NOT recreate the cache. In other words, the
    rest of
    the tag isn't run (well, mostly, but don't worry).
    clearAll: Removes all data from this scope. Exits the tag
    immidiately.
    disabled: Allows for a quick exit out of the tag. How would
    this be used? You can
    imagine using disabled="#request.disabled#" to allow for a
    quick way to
    turn on/off caching for the entire site. Of course, all
    calls to the tag
    would have to use the same value.
    License : Use this as you will. If you enjoy it and it helps
    your application,
    consider sending me something from my Amazon wish list:
    http://www.amazon.com/o/registry/2TCL1D08EZEYE
    --->
    <cfcomponent>
    <cffunction name="scope_Cache" access="public"
    returntype="string">
    <cfargument name="cachename" type="string"
    required="yes">
    <cfargument name="scope" type="string" required="yes">
    <cfargument name="timeout" type="string"
    required="yes">
    <cfprocessingdirective pageencoding="utf-8">
    <!--- allow for quick exit
    <cfif isDefined("arguments.disabled") and
    arguments.disabled>
    <cfexit method="exitTemplate">
    </cfif>
    <!--- Allow for cachename in case we use cfmodule --->
    <cfif isDefined("arguments.cachename")>
    <cfset arguments.name = arguments.cachename>
    </cfif>--->
    <!--- Attribute validation --->
    <cfif (not isDefined("arguments.name") or not
    isSimpleValue(arguments.name)) and not
    isDefined("arguments.clearall")>
    <cfthrow message="scopeCache: The name attribute must be
    passed as a string.">
    </cfif>
    <cfif not isDefined("arguments.scope") or not
    isSimpleValue(arguments.scope) or not
    listFindNoCase("application,session,server",arguments.scope)>
    <cfthrow message="scopeCache: The scope attribute must be
    passed as one of: application, session, or server.">
    </cfif>
    <!--- The default timeout is no timeout, so we use the
    year 3999. --->
    <cfparam name="arguments.timeout"
    default="#createDate(3999,1,1)#">
    <!--- Default dependancy list --->
    <cfparam name="arguments.dependancies" default=""
    type="string">
    <cfif not isDate(arguments.timeout) and (not
    isNumeric(arguments.timeout) or arguments.timeout lte 0)>
    <cfthrow message="scopeCache: The timeout attribute must
    be either a date/time or a number greather zero.">
    <cfelseif isNumeric(arguments.timeout)>
    <!--- convert seconds to a time --->
    <cfset arguments.timeout =
    dateAdd("s",arguments.timeout,now())>
    </cfif>
    <!--- create pointer to scope --->
    <cfset ptr = structGet(arguments.scope)>
    <!--- init cache root --->
    <cfif not structKeyExists(ptr,"scopeCache")>
    <cfset ptr["scopeCache"] = structNew()>
    </cfif>
    <cfif isDefined("arguments.clearAll")>
    <cfset structClear(ptr["scopeCache"])>
    <cfexit method="exitTag">
    </cfif>
    <!--- This variable will store all the guys we need to
    update --->
    <cfset cleanup = "">
    <!--- This variable determines if we run the caching.
    This is used when we clear a cache --->
    <cfset dontRun = false>
    <cfif isDefined("arguments.clear") and arguments.clear
    and structKeyExists(ptr.scopeCache,arguments.name) and
    thisTag.executionMode is "start">
    <cfif
    structKeyExists(ptr.scopeCache[arguments.name],"dependancies")>
    <cfset cleanup =
    ptr.scopeCache[arguments.name].dependancies>
    </cfif>
    <cfset structDelete(ptr.scopeCache,arguments.name)>
    <cfset dontRun = true>
    </cfif>
    <cfif not dontRun>
    <cfif thisTag.executionMode is "start">
    <!--- determine if we have the info in cache already
    --->
    <cfif structKeyExists(ptr.scopeCache,arguments.name)>
    <cfif
    dateCompare(now(),ptr.scopeCache[arguments.name].timeout) is -1>
    <cfif not isDefined("arguments.r_Data")>
    <cfoutput>#ptr.scopeCache[arguments.name].value#</cfoutput>
    <cfelse>
    <cfset caller[arguments.r_Data] =
    ptr.scopeCache[arguments.name].value>
    </cfif>
    <cfexit>
    </cfif>
    </cfif>
    <cfelse>
    <!--- It is possible I'm here because I'm refreshing. If
    so, check my dependancies --->
    <cfif structKeyExists(ptr.scopeCache,arguments.name) and
    structKeyExists(ptr.scopeCache[arguments.name],"dependancies")>
    <cfif
    structKeyExists(ptr.scopeCache[arguments.name],"dependancies")>
    <cfset cleanup = listAppend(cleanup,
    ptr.scopeCache[arguments.name].dependancies)>
    </cfif>
    </cfif>
    <cfset ptr.scopeCache[arguments.name] = structNew()>
    <cfif not isDefined("arguments.data")>
    <cfset ptr.scopeCache[arguments.name].value =
    thistag.generatedcontent>
    <cfelse>
    <cfset ptr.scopeCache[arguments.name].value =
    arguments.data>
    </cfif>
    <cfset ptr.scopeCache[arguments.name].timeout =
    arguments.timeout>
    <cfset ptr.scopeCache[arguments.name].dependancies =
    arguments.dependancies>
    <cfif isDefined("arguments.r_Data")>
    <cfset caller[arguments.r_Data] =
    ptr.scopeCache[arguments.name].value>
    </cfif>
    </cfif>
    </cfif>
    <!--- Do I need to clean up? --->
    <cfset z = 1>
    <cfloop condition="listLen(cleanup)">
    <cfset z = z+1><cfif z gt 100><cfthrow
    message="ack"></cfif>
    <cfset toKill = listFirst(cleanup)>
    <cfset cleanUp = listRest(cleanup)>
    <cfif structKeyExists(ptr.scopeCache, toKill)>
    <cfloop index="item"
    list="#ptr.scopeCache[toKill].dependancies#">
    <cfif not listFindNoCase(cleanup, item)>
    <cfset cleanup = listAppend(cleanup, item)>
    </cfif>
    </cfloop>
    <cfset structDelete(ptr.scopeCache,toKill)>
    </cfif>
    </cfloop>
    <cfreturn scope_Cache>
    </cffunction>
    </cfcomponent>

    Hi, thanks to both of you for your help. I reverted back the
    custom tag and it was picked up this time - I don't know what
    happened before. The functionality works as expected but I have hit
    another problem and I am hoping I can tap your combined ColdFusion
    wisdom to solve!!
    The calendar returns leave records for staff and filters the
    records using a querystring variable appended when the user clicks
    on a particular month. However, what members of staff the user sees
    depends on the data held in the users' session variables based on
    their authority. The reason I wanted to use caching is because the
    page takes a good ten seconds to run because of the use of cfloops
    for the members of staff and the days of the week to dynamically
    build the page. Using the custom tag would have worked if all
    members of staff saw the same calendar data and could only see one
    month. Can you see anyway I can speed up the page and do you think
    caching is the way forward here?

  • JSP in custom tag attributes...

    Sirs,
              A very nice feature from a development perspective, would be the ability
              to use JSP code within custom tags. Say I have a page on which I wish
              to give all the information on a widget. Say further that I have
              implemented a tag that writes out all the info of a widget as HTML
              table. I would like to write something like this:
              <mytaglib:widgetTag widgetID="<%=request.getParameter("widget_id")%>"
              />
              As far as I know, in the current implementation of custom taglibs this
              does not seem to be possible. Instead you end up writing something like
              this:
              <mytaglib:widgetTag>
              <mytaglib:getWidget><%=request.getParameter("widget_id")%>"</mytaglib:getWidget>
              <mytaglib:displayWidget />
              </mytaglib:widgetTag>
              Which is much more like a scripting language than a heirarchical XML .
              Now, I could always just use the request object within the tag helper
              classes, but this gives up flexibility and can introduce security
              issues, and it also makes the tags much more difficult to work with...
              In short, we should push for JSP evaluation of tag attributes. Weblogic
              could leap ahead of other app servers in this area (making up for the
              custom tag performance issues, to be solve in sp6) and Sun would, once
              again, follow Weblogic's lead and rewrite the standard to include this
              functionality.
              Regards,
              Carson Gross
              

    Carson,
              Perhaps the problem is that you are treating custom tags like one would
              construct an imperative language. I have never had to put Java or use beans
              or %= or even parameters to tags into a JSP because of custom tags.
              The real problem is writing/packaging/maintaining all those tags; sure could
              use a tool that did just that ;-)
              Peace,
              Cameron Purdy
              [email protected]
              http://www.tangosol.com
              WebLogic Consulting Available
              "Carson Gross" <[email protected]> wrote in message
              news:[email protected]...
              > Sirs,
              >
              > A very nice feature from a development perspective, would be the ability
              > to use JSP code within custom tags. Say I have a page on which I wish
              > to give all the information on a widget. Say further that I have
              > implemented a tag that writes out all the info of a widget as HTML
              > table. I would like to write something like this:
              >
              > <mytaglib:widgetTag widgetID="<%=request.getParameter("widget_id")%>"
              > />
              >
              > As far as I know, in the current implementation of custom taglibs this
              > does not seem to be possible. Instead you end up writing something like
              > this:
              >
              > <mytaglib:widgetTag>
              >
              >
              <mytaglib:getWidget><%=request.getParameter("widget_id")%>"</mytaglib:getWid
              get>
              >
              > <mytaglib:displayWidget />
              > </mytaglib:widgetTag>
              >
              > Which is much more like a scripting language than a heirarchical XML .
              > Now, I could always just use the request object within the tag helper
              > classes, but this gives up flexibility and can introduce security
              > issues, and it also makes the tags much more difficult to work with...
              >
              > In short, we should push for JSP evaluation of tag attributes. Weblogic
              > could leap ahead of other app servers in this area (making up for the
              > custom tag performance issues, to be solve in sp6) and Sun would, once
              > again, follow Weblogic's lead and rewrite the standard to include this
              > functionality.
              >
              > Regards,
              > Carson Gross
              >
              

  • Dynamic include inside custom tag body

    I am trying to perform the dynamic include of another JSP from within the body of a custom tag using JSP1.1. It cannot be done using <jsp:include> since flush=true is required and thus an exception is thrown when called from inside the body of a custom tag - it can be done in JSP1.2 since flush does not have to be set to true but upgrading is not possible at this time.
    Does anyone know of any custom tag or the code needed to perform this function with JSP1.1?
    I am using Tomcat 3.2.3.
    Using a RequestDispatcher and calling include() does not have the desired effect since the output is witten directly to the response and does not go into the correct position in the calling JSP.
    I think the solution involves making a call to the included JSP (is it possible to use a RequestDispatcher that doesn't write directly to the page output stream?) and then append the response to the BodyContent object which is buffering the body content of the custom tag until the doAfterBody() method is called. Is it possible to create a dummy ServletResponse object to pass to the RequestDispatcher and then obtain the HTML response from the internal buffer?

    I don't know if there is a solution to the problem you are having with JSP 1.1. If you look in the spec, it actually warns you that dynamic includes can not be done inside a body tag. The spec actually states that the included code shout write directly to the response and not to the BodyContent.
    I was excited to find out they had fixed this in JSP 1.2, but they seem to have foiled me again. If my tag calls PageContext.include(), the spec says that include must call the flush method, which causes BodyContent to throw an exception since flush is not a valid call.

  • Custom tag problem (parent/child tag)

    I have a table tag and a column tag that I'm using in my application to display records.
    The first time through it sets up headers and keeps a coun't of the columns.
    The second time through it starts putting data in the fields. The problem I'm having is that I set a counter in the column tag. When it hits the first column it increments it from 0 to 1. When it hits the second column the counter has lost its value and is back to 0.
    This only occurs if I have the align="Left". Or more precisely when some of the columns have align and some don't.... To fix this I can add align="right" to all the columns... but I have it defaulting to right and don't think I should have to include it.. can someone explain to me why this is occuring?
    <xxx:table name="columnData" scope="request" scrollable="Yes">
         <xxx:column key="selectorColumn:FILEID" title="Select" />
         <xxx:column key="50" title="VTFHBRForm.de50" align="Left"/>
         <xxx:column key="110" title="VTFHBRForm.de110" />
         <xxx:column key="330" title="VTFHBRForm.de330" />
         <xxx:column key="320" title="VTFHBRForm.de320" />
         <xxx:column key="160" title="VTFHBRForm.de160" />
         <xxx:column key="5" title="VTFHBRForm.de5" />
         <xxx:column key="500" title="VTFHBRForm.de500" />
         <xxx:column key="510" title="VTFHBRForm.de510" />
         <xxx:column key="240" title="VTFHBRForm.de240" />
         <xxx:column key="150" title="VTFHBRForm.de150" />
         <xxx:column key="170" title="VTFHBRForm.de170" />
         <xxx:column key="140" title="VTFHBRForm.de140" />
         <xxx:column key="480" title="VTFHBRForm.de480" />
         <xxx:column key="172" title="VTFHBRForm.de172" />
         <xxx:column key="270" title="VTFHBRForm.de270" />
    </xxx:table>

    u have not define what child tad retrieves (null?) or u mean to say EL is not evaluated...
    because in my tag i had faced the problem for not evaluating the EL.
    (although i had done rexp...=true).
    could u put ur custom tag code then perhaps, i could say the solutiong

  • Custom Tag and CFC : Nate Weiss

    Hi,
    being a beginner I'm trying with some marginal degree of
    success to understand CFC's and Custome Tags.
    In the CFMX7 W.A.C.K. There is an example shopping cart. This
    start off as a basic affair then expands into more object based
    principles using a custom tag add products to the cart
    (ShoppingCart.cfc) and later on the same page uses a custome Tag to
    display the cart items, calling it once for each item to display.
    I am using the MVC structure under Fusebox 4, so this method
    of using the same template, (reloading etc) is alien to me as with
    MVC you usually have the data type intructions in different files
    (anyway, I digress)
    Now that I have the thing adding products and generally
    working with my "shop", I thought about having a "special offer"
    facility. With these "Hot Deals" being stored in another database
    table, with their productID and new price.
    However, obviously the shopping cart needs to be made aware
    of this. With I would have thought an extra variable in the array
    telling the custom tag to retrieve the special price and the
    product information using a diufferent inner join query to normal.
    I have attemtped this by adding an additional URL parameter
    thus /..../HSOP/Y ("Has Special Offer Price" being set to "Y")
    When this reloads the page the CFC invoke is set thus
    <CFIF IsDefined("URL.HSOP") AND #URL.HSOP# EQ "Y">
    <CFINVOKE
    COMPONENT="#SESSION.MyShoppingCart#"
    METHOD="Add"
    MERCHID="#URL.AddMerchID#"
    SOPH="Y">
    <cfelse>
    This successfully passes
    Add(SOPH = Y, MERCHID = xxxx)
    to the CFC. However I get this error......,
    ..................Element SOPH is undefined in ARGUMENTS.
    the CFC simpley isnt adding the new variable to the array...
    I think... it wont do a CFDump so there is no way of telling
    <CFFUNCTION
    NAME="Add"
    HINT="Adds an item to the shopping cart">
    <!--- Three Arguments: MerchID, Quantity and SOPH (flag
    to state if there is a special price) --->
    <CFARGUMENT NAME="MerchID" TYPE="numeric"
    REQUIRED="Yes">
    <CFARGUMENT NAME="Quantity" TYPE="numeric" REQUIRED="No"
    DEFAULT="1">
    <CFARGUMENT NAME="SOPH" type="string">
    <!--- Get structure that represents this item in cart,
    --->
    <!--- then set its quantity to the specified quantity
    --->
    <CFSET CartItem = GetCartItem(MerchID)>
    <CFSET CartItem.Quantity = CartItem.Quantity +
    Arguments.Quantity>
    <CFSET CartItem.SOPH = Arguments.SOPH>
    </CFFUNCTION>
    I cant see why this wouldn't create the variable
    "CartItem.SOPH" and set it to "Y" as passed to it.
    I notice the CFC performs an iteration of sorts to put the
    cart items into an array. But I'm afraid I cant fathom what this
    problem might be.
    Any ideas. I have attached the whole CFC code (post editing
    by me)
    MAny thanks and Happy new Year

    Hi,
    As for me, I am testing the related pdf-417 barcode scanner these days. Do you have any ideas about it? Or any good suggestion? I am totally a green hand on barcode field. Any suggestion will be appreciated. Thanks in advance.
    Best regards,
    Arron

  • Tree view custom tag

    Hi all,
    Is there a custom tag available for rendering packages off all classes loaded in a classloaders into a tree?
    I already have an iterator containing the wanted packages.
    Thanks in advance for your help,
    Kind regards

    I'm trying out the JSP tree tag library from Guy Davis at http://www.guydavis.ca/projects/oss/tags/
    Does anyone know a performant algoritm to loop over a collection like the following :
    x.y.Class1
    x.y.z.Class2
    x.y.z.Class3
    x.Class4
    Class5
    All classes have to recieve a level to add in the tree.
    Any idea's?
    Kind regards,

Maybe you are looking for

  • Cant find imovie, iphoto and the rest of ilife app

    Hello! A few days ago I got my macbook pro (late 2011). I delivered it to the service and when i got it back I cant find imovie, iphoto, garage band that I had before i delivered it to the service. What has happend and how do I get these programs bac

  • Acrobat Will Not Allow Save?

    I have Acrobat 9, Pro Extended (9.5.5). Running on Windows 7 Proffesional. Also in case relevant, MS Office 2007. Autocad 2009Adobe Photoshop, Illustrator and Indesign CS4. I create files mostly from programs such as Autocad, MS Word, MS Excel, or ot

  • I cannot delete some of my downloads, including a rogue one

    I have a number of downloads I no longer need, but cannot see how to delete them. Now I have one which is a scam and I urgently need to get this off the system but am unable to do so.

  • Applying tooltip styles from defaults.css file problem

    in flex library, create custom tooltip extend ToolTip CustomToolTip code: public class CustomToolTip extends ToolTip then i want use custom skin like ToolTipBorderSkin, so i add into defaults.css defaults.css code: CustomToolTip borderSkin: ClassRefe

  • Slide Presentation in ScrollPane

    I load a Flash Professional Slide Presentation into a scrollPane. Is it possible to figure out which slide is currently being presented from the scrollPane and/or Parent of the scrollPane? If so, how? Thanks.