Generate & using Javascript in custom Tag

Hi everyone,
I'm developing a custom tag to create a treeview from a TreeModel.
I've got a script found on the web which uses a few javascripts file.
My question is :
How do i have to use my javascripts file ?
Do i have to just import the javascipt files in my project ? (i.e. in a directory called "scripts"). Or do the javascripts have to be only available for my tag.
Of course, the javascripts for the tag should only be used by the tag.
So, if anyone can give my what's the best practice.
Thank's
Sebastien Degardin

Javascript runs only on the client.
So the javascript file needs to be on your web server, and your jsp page needs to import that script using the <script> tag.
It doesn't necessarily need to be in your java project, as it is not needed at compile time. Consider it a static resource like an image or a .html file.
Basically your JSP is then just generating javascript code that will run on the client.

Similar Messages

  • How can i use JSTL inside custom tag attribute

    Hi,
    I have one button tag which displays the button with round corner. I will show the button like this:
    <ep:button key="buttons.submit" name="submitBtn" styleClass="But"
              onClick='submitPage(''<c:out value='${buttonName}' />)' />
    I am getting the problem with the above code. how can i use JSTL inside the custom tags.
    Thanks in Advance,
    LALITH

    No. The details are given below:
    I have included the follwing line in web.xml file:
    <taglib>
        <taglib-uri>/tags/button</taglib-uri>
        <taglib-location>/WEB-INF/button.tld</taglib-location>
      </taglib>button.tld file
    <taglib>
         <tlibversion>1.0</tlibversion>
         <jspversion>2.0</jspversion>
         <shortname>button</shortname>
         <tag>
              <name>button</name>
              <tagclass>com.ksi.ep.web.taglib.ButtonTag</tagclass>
              <bodycontent>empty</bodycontent>
              <attribute>
                   <name>name</name>
                   <required>true</required>
                   <rtexprvalue>false</rtexprvalue>
              </attribute>
              <attribute>
                   <name>key</name>
                   <required>true</required>
                   <rtexprvalue>true</rtexprvalue>
              </attribute>
              <attribute>
                   <name>onClick</name>
                   <required>true</required>
                   <rtexprvalue>true</rtexprvalue>
              </attribute>
    </taglib>ButtonTag.java :
    public class ButtonTag extends TagSupport {
       private static final long serialVersionUID = 6837146537426981407L;
         * Initialise the logger for the class
        protected final transient Log log = LogFactory.getLog(ButtonTag.class);
         *  holds the Value of the button tag
        protected String onClick = null;
         *  holds message resources key
        protected String key = null;
         * The message resources for this package.
        protected static MessageResources messages =
                             MessageResources.getMessageResources
                                       ("ApplicationResources");
          *  (non-Javadoc)
          * @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
         public int doStartTag() throws JspException {    
            StringBuffer label = new StringBuffer();         
            HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
            try {             
                   log.debug("in doStartTag()");
                   Locale locale = pageContext.getRequest().getLocale();
                 if (locale == null) {
                     locale = Locale.getDefault();
                 log.info("");
                 label.append("<a border=\"0\" style=\"text-decoration:none;color:#FFFFFF\" href=\"JavaScript:");
                 label.append(onClick);
                 label.append("\" >");
                   label.append("<table  onClick=\"");
                   label.append(onClick);               
                   label.append("\" ");
                   if(onmouseout!=null && !"".equalsIgnoreCase(onmouseout))
                    label.append(" onmouseout=\"");
                    label.append(onmouseout);               
                    label.append("\" ");
                   if(onmouseover!=null && !"".equalsIgnoreCase(onmouseover)){
                    label.append(" onmouseover=\"");
                    label.append(onmouseover);               
                    label.append("\" ");
                   if(title!=null && !"".equalsIgnoreCase(title)){
                    label.append(" title=\"");
                    label.append(title);               
                    label.append("\" ");
                   label.append("style=\"cursor:hand\" tabindex=\"1\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"");
                   label.append(request.getContextPath());
                   label.append(System.getProperty("file.separator"));
                   label.append("images");
                   label.append(System.getProperty("file.separator"));
                   label.append("background1.jpg\" > ");
                 label.append("<tr><td width=\"10\"><img  border=\"0\" src=\"");
                 label.append(request.getContextPath());
                   label.append(System.getProperty("file.separator"));
                   label.append("images");
                   label.append(System.getProperty("file.separator"));
                 label.append("leftcorner.jpg\" ></td> ");
                 label.append("<td valign=\"middle\"  style=\"padding-bottom:2px\"><font color=\"#FFFFFF\" style=\"");
                 label.append(styleClass);
                 label.append("\">");
                 label.append(messages.getMessage(key));
                 label.append("</font></td>");
                 label.append("<td width=\"10\" align=\"right\"><img src=\"");
                 label.append(request.getContextPath());
                   label.append(System.getProperty("file.separator"));
                   label.append("images");
                   label.append(System.getProperty("file.separator"));            
                 label.append("rightcorner.jpg\" border=\"0\"  ></td>");
                 label.append("</tr></table></a>");
                 pageContext.getOut().print(label.toString());
              } catch (Exception e) {               
                   log.error("Exception occured while rendering the button", e);
                   throw new JspException(e);
            return (SKIP_BODY);
         * Release all allocated resources.
        public void release() {       
            this.name=null;
            this.key=null;
            this.onClick=null;
    }In my JSP I have mentioned the taglib directive as
    <%@ taglib uri="/tags/button" prefix="ep"%>and
    <ep:button key="buttons.submit" name="submitBtn" styleClass="But"
         onClick='overwritePreApprovals('<c:out value='${transactionalDetails['inPrepList']}' />')' />Servlet.service() for servlet action threw exception
    org.apache.jasper.JasperException: /pages/pms/coordinator/Dashboard.jsp(325,48) Unterminated <ep:button tag
    Thanks,
    LALITH

  • How do I configure portal desktop to use my own custom tag in template?

    I seem to have tried everything. I want to use a custom tag from a jar file on a template JSP. I keep getting error saying tag library not found. I have the tld in the meta-inf of the jar. I tried putting the jar in the desktop classes, the deployed WEB-INF lib directory for portal, in the web-src directory for the portal. I tried configuring the uri in the web.xml for the portal webapp. None of these have worked. Does someone know how to do this? If someone could help out that would be great. I tries the jar from a web application and it worked fine. I just need to get this working with Portal Server.
    Thanks,
    Frank

    Thank you for the reply Alex. We are using the Dynamics AX 2012 R3 ISO for our installation. In the software requirement documentation for Dynamics AX it says that is able to run on Windows Server 2012 R2. I believe the prerequisites for Dynamics AX and
    Dynamics CRM are different. We received a response from another forum that you can change the .NET version that Sharepoint 2010 uses through IIS in the application pool, but even after setting it to .NET v2.0, we still receive the error in the Dynamics log
    that says it is not compatible with .NET v4.0. So I suppose the question is, where does the Dynamics AX 2012 R3 prerequisite checker look to see which version of .NET Sharepoint is using?
    Thanks again for the reply!

  • Using EL in custom tag with JSP1.2 container

    I search the the Forum here and Google for a method how I can use expression language in my custom tag. But I have to use a JSP1.2 container which makes it quite difficult. What I need is startsWith-Tag which looks like this.
    <str:startsWith condition1="${sql.rows[0].MY_COLUMN}" condition2="MyCondition">
    </str:startsWith>Right now my tag works, but instead of the database of MY_COLUMN the string ${sql.rows[0].MY_COLUMN} is submitted.
    In the TLD I specified rtexprvalue with true. My custom tag extends javax.servlet.jsp.jstl.core.ConditionalTagSupport.
    What I read here was that I have to evaluate the el expression myself, but how do I do this? I hope someone can give me a hint how to make the tag working correctly.
    TIA
    Axel

    You might find the source code of MicroNova YUZU (http://sourceforge.net/projects/micronova-yuzu) useful. It is an EL-based tag library that supports both JSP 1.2 and 2.0. See "jsp12" and "jsp20" subdirectories for version-specific EL handling. Hope this helps.

  • Tin Can Statements using Javascript on Custom Buttons

    Has anyone got custom Tin Can Statements working using Javascript Actions on custom buttons using advanced actions in Adobe Captivate?

    Thanks for the reply.  So just to be sure, there is no way to approach doing what is mentioned below: 
    Captivate may be using TinCanJS (http://rusticisoftware.github.io/TinCanJS/) under the hood. If it is, then it might be exposing a global `TinCan` variable and potentially another global that is an instance of that constructor that has the configured LRSs. If that is the case, then it should be trivial to add a call to the 'sendStatement' method of that interface and it should Just Work (tm). You should be able to launch the course and use browser developer tools to inspect the global namespace to see what objects are available.
    If the TinCan global is there but you don't see anything representing an instance of it, then you can always create your own instance and use the 'url' property of the constructor to get one configured with an LRS instance from the launch parameters. Then follow the same procedure as above.
    If the TinCan global isn't there then you can load TinCanJS yourself which will give you that global and then follow the procedures in both of the above. The Tin Can Prototypes (http://tincanapi.com/prototypes/) include examples of working with the TinCanJS library both in launch and non-launch scenarios. From a developer purist perspective loading the lib as your own dependency is really more proper anyways so that you control the dependency and its version, but TinCanJS doesn't currently support a "no conflict" type of feature without special build, so if it is already present you are best off using the version loaded on the page so as not to risk breaking other parts of the course.

  • Composing mail from email web application using jsp and custom tags

    here is the send.jsp file
    <%@ page language="java" %>
    <%@ page errorPage="errorpage.jsp" %>
    <%@ taglib uri="http://java.sun.com/products/javamail/demo/webapp"
    prefix="javamail" %>
    <html>
    <head>
         <title>JavaMail send</title>
    </head>
    <body bgcolor="white">
    hi
    <javamail:sendmail
    recipients="<%= request.getParameter(\"to\") %>"
    sender="<%= request.getParameter(\"from\") %>"
    subject="<%= request.getParameter(\"subject\") %>">
    <%= request.getParameter("text") %>
    </javamail:sendmail>
    <h1>Message sent successfully</h1>
    </body>
    </html>
    Here is the java file i.e used to refer to this custom tag
    package taglib;
    import java.util.*;
    import java.net.*;
    import javax.mail.*;
    import javax.mail.Authenticator;
    import javax.mail.internet.*;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    * Custom tag for sending messages.
    public class SendTag extends BodyTagSupport {
    private String body;
    private String cc;
    private String host;
    private String recipients;
    private String sender;
    private String subject;
    * host attribute setter method.
    public void setHost(String host) {
    this.host = host;
    System.out.println("Host is : " +host);
    * recipient attribute setter method.
    public void setRecipients(String recipients) {
    this.recipients = recipients;
    System.out.println("recipients is " +recipients );
    * sender attribute setter method.
    public void setSender(String sender) {
    this.sender = sender;
    System.out.println("Sender is : " +sender);
    * cc attribute setter method.
    public void setCc(String cc) {
    this.cc = cc;
    * subject attribute setter method.
    public void setSubject(String subject) {
    this.subject = subject;
    System.out.println("subject is : " +subject);
    * Method for processing the end of the tag.
    public int doEndTag() throws JspException {
         System.out.println(" ** In do end tag");
    Properties props = System.getProperties();
    try {
    if (host != null)
    props.put("mail.smtp.host", host);
    else if (props.getProperty("mail.smtp.host") == null)
    props.put("mail.smtp.host", InetAddress.getLocalHost().
    getHostName());
    } catch (Exception ex) {
    throw new JspException(ex.getMessage());
    Session session = Session.getDefaultInstance(props,null);
         Message msg = new MimeMessage(session);
         InternetAddress[] toAddrs = null, ccAddrs = null;
    try {
         if (recipients != null) {
         toAddrs = InternetAddress.parse(recipients, false);
         msg.setRecipients(Message.RecipientType.TO, toAddrs);
         } else
         throw new JspException("No recipient address specified");
    if (sender != null)
    msg.setFrom(new InternetAddress(sender));
    else
    throw new JspException("No sender address specified");
         if (cc != null) {
    ccAddrs = InternetAddress.parse(cc, false);
         msg.setRecipients(Message.RecipientType.CC, ccAddrs);
         if (subject != null)
         msg.setSubject(subject);
         if ((body = getBodyContent().getString()) != null)
         msg.setText(body);
    else
    msg.setText("");
    Transport.send(msg);
    } catch (Exception ex) {
    throw new JspException(ex.getMessage());
    return(EVAL_PAGE);
    all the entries in taglib.tld and web.xml are correct.
    It is one of the article given at this url:
    http://java.sun.com/developer/technicalArticles/javaserverpages/emailapps/

    First, you should not take copyrighted code and post it without a copyright.
    The code you posted is copyright Sun Microsystems.
    Second, why did you post it? Did you have a question?

  • How to use the JRun Custom tag library wiith Weblogic 5.1?

    Hello,
    is it possible to use the JRUN Tag Library with Bea Weblogic 5.1? We
    got an error message like:
    weblogic.servlet.jsp.JspException: (line -1): Error in tag library at:
    'jrun': T
    here is no setter method for property 'code', for Tag class
    'allaire.taglib.Serv
    letTag'
    Thank you for any info!
    Stefan

    Hi Joe,
    I don't know, however someone that follows the JSP newsgroup [1] may be
    able to help. Could you try your post there.
    Thanks,
    Bruce
    [1]
    http://newsgroups.bea.com/cgi-bin/dnewsweb?cmd=xover&group=weblogic.developer.interest.jsp
    Joe Kamenar wrote:
    >
    I have a question. I need to do a sort on news articles in our database, sorting
    by the date they were posted. I then want to take only the top 6 articles. We
    are using Weblogic 5.1. When I use the following statement, 6 articles are taken
    from the database, then sorted, which ends up leaving out the most recent articles:
    <cm:select contentHome="com.beasys.commerce.axiom.document.Document" query="<%=contentQuery%>"
    sortby = "creationDate DESC, headlineDate DESC" max="6" id="contentList" />
    I need to get ALL the articles for the sort, then just take the most recent 6.
    So, I know that I can use the following code and monitor the counter variable,
    "i". But, how do i do this to only display the top 6 items?
    <es:foreachinarray id="content" array="contentList" type="com.beasys.commerce.axiom.content.Content"
    counterId="i">
    <% myStr=content.getIdentifier(); %>
    <% if (i<6) {
    %>
    <div class="marginText">
    <cm:printproperty id="content" name="title" encode="html" />  
    <a href="<%=new String(news_display.jsp?id="+myStr)%">">more</a>
    </div>
    <% } %>
    </es:foreachinarray>
    However, when I run this, no results show up. What is the correct way to do this?
    - Joe</a>

  • How to use the JRun Custom tag library with Weblogic 5.1?

    Hello,
              is it possible to use the JRUN Tag Library with Bea Weblogic 5.1? We
              got an error message like:
              weblogic.servlet.jsp.JspException: (line -1): Error in tag library at:
              'jrun': T
              here is no setter method for property 'code', for Tag class
              'allaire.taglib.Serv
              letTag'
              Thank you for any info!
              Stefan
              

    Hi Joe,
    I don't know, however someone that follows the JSP newsgroup [1] may be
    able to help. Could you try your post there.
    Thanks,
    Bruce
    [1]
    http://newsgroups.bea.com/cgi-bin/dnewsweb?cmd=xover&group=weblogic.developer.interest.jsp
    Joe Kamenar wrote:
    >
    I have a question. I need to do a sort on news articles in our database, sorting
    by the date they were posted. I then want to take only the top 6 articles. We
    are using Weblogic 5.1. When I use the following statement, 6 articles are taken
    from the database, then sorted, which ends up leaving out the most recent articles:
    <cm:select contentHome="com.beasys.commerce.axiom.document.Document" query="<%=contentQuery%>"
    sortby = "creationDate DESC, headlineDate DESC" max="6" id="contentList" />
    I need to get ALL the articles for the sort, then just take the most recent 6.
    So, I know that I can use the following code and monitor the counter variable,
    "i". But, how do i do this to only display the top 6 items?
    <es:foreachinarray id="content" array="contentList" type="com.beasys.commerce.axiom.content.Content"
    counterId="i">
    <% myStr=content.getIdentifier(); %>
    <% if (i<6) {
    %>
    <div class="marginText">
    <cm:printproperty id="content" name="title" encode="html" />  
    <a href="<%=new String(news_display.jsp?id="+myStr)%">">more</a>
    </div>
    <% } %>
    </es:foreachinarray>
    However, when I run this, no results show up. What is the correct way to do this?
    - Joe</a>

  • How to use JSP custom tag lib in PAR file?

    Hi All,
    I am trying to customize mastheaderpar file. For that I have downloaded relevant par file and making the changes accordingly.
    As part of the changes I would require to use JSP custom tag library in my par file.
    I have the TLD file and relevant classes in the jar file. I would like to know where and what kind of modifications have to be done to use the jsp custom tag library.
    I tried modifying some things in portalapp.xml but was not successful.
    Please help me on how to proceed with this? It would be great if you can provide the xml entry to use this tag library
    Thanks
    Santhosh

    Hi Johny,
    Thanks for the reply. Actually I am able to change colors etc. with out any problem.
    My requirement is to use XMLTaglib in mastheader par file. This tag lib is from apache tomcat. I have the relevant TLD and class files. I copied TLD file into taglib dir of portal-inf and class file in src api.
    And I have added the following line in portalapp.xml under component-profile section of default
    <property name="tlxtag" value="/SERVICE/Newmastheader/taglib/taglibs-xtags.tld">
    Is this the right way to use tag lib? Actually before adding this line I used to get the error saying "Error parsing taglib", but now the error does not occur and I am getting new error. This is an exception in one of the taglib classes.
    Could any one provide me some inputs on how to check this error?
    Thanks
    Santhosh

  • 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
              > > >
              > > >
              > >
              > >
              >
              >
              

  • Connection Pooling and JSP Custom Tag Library - is code (inside) the best way/correc?

    Hi, can anyone advise as to whether my tag library code (based
    on Apache Jakarta Project) will actually achieve connection
    pooling functionality across my entire JSP based application? I
    am slightly concerned that my OracleConnectionCacheImpl object
    may exist multiple times, hence rendering my conection pooling
    attempt useless.
    package com.solved.tag.dbtags.connection;
    import java.io.IOException;
    import java.sql.Connection;
    import java.sql.SQLException;
    import javax.servlet.jsp.tagext.TagSupport;
    import javax.servlet.jsp.JspTagException;
    import javax.sql.DataSource;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import oracle.jdbc.pool.OracleConnectionCacheImpl;
    * <p>JSP tag connection, used to get a
    * java.sql.Connection object.</p>
    * <p>JSP Tag Lib Descriptor
    * <pre>
    * &lt;name>connection&lt;/name>
    &lt;tagclass>com.solved.tag.dbtags.connection.ConnectionTag&lt;/t
    agclass>
    * &lt;bodycontent>JSP&lt;/bodycontent>
    &lt;teiclass>com.solved.tag.dbtags.connection.ConnectionTEI&lt;/t
    eiclass>
    * &lt;info>Opens a connection based on a jndiName.&lt;/info>
    * &lt;attribute>
    * &lt;name>id&lt;/name>
    * &lt;required>true&lt;/required>
    * &lt;rtexprvalue>false&lt;/rtexprvalue>
    * &lt;/attribute>
    * </pre>
    * @author Matt Shannon
    public class ConnectionTag extends TagSupport {
    static private OracleConnectionCacheImpl cache = null;
    public int doStartTag() throws JspTagException {
    try {
    Connection conn = null;
    if (cache == null) {
    try {
    InitialContext ic = new InitialContext();
    DataSource ds = (DataSource) ic.lookup
    ("jdbc/pool/OracleCache");
    cache = (OracleConnectionCacheImpl)ds;
    catch (NamingException ne) {
    throw new JspTagException(ne.toString());
    conn = cache.getConnection();
    pageContext.setAttribute(getId(),conn);
    catch (SQLException e) {
    throw new JspTagException(e.toString());
    return EVAL_BODY_INCLUDE;
    package com.solved.tag.dbtags.connection;
    import java.sql.Connection;
    import java.sql.SQLException;
    import javax.servlet.jsp.tagext.TagSupport;
    * <p>JSP tag closeconnection, used to close the
    * specified java.sql.Connection.<p>
    * <p>JSP Tag Lib Descriptor
    * <pre>
    * &lt;name>closeConnection&lt;/name>
    &lt;tagclass>com.solved.tag.dbtags.connection.CloseConnectionTag&
    lt;/tagclass>
    * &lt;bodycontent>empty&lt;/bodycontent>
    * &lt;info>Close the specified connection. The "conn"
    attribute is the name of a
    * connection object in the page context.&lt;/info>
    * &lt;attribute>
    * &lt;name>conn&lt;/name>
    * &lt;required>true&lt;/required>
    * &lt;rtexprvalue>false&lt;/rtexprvalue>
    * &lt;/attribute>
    * </pre>
    * @author Matt Shannon
    * @see ConnectionTag
    public class CloseConnectionTag extends TagSupport {
    private String _connId = null;
    * The "conn" attribute is the name of a
    * page context object containing a
    * java.sql.Connection.
    * @param connectionId
    * attribute name of the java.sql.Connection to
    close.
    * @see ConnectionTag
    public void setConn(String connectionId) {
    _connId = connectionId;
    public int doStartTag() {
    try {
    Connection conn = (Connection)pageContext.getAttribute
    (_connId);
    conn.close();
    } catch (SQLException e) {
    // failing to close a connection is not fatal
    e.printStackTrace();
    return EVAL_BODY_INCLUDE;
    public void release() {
    _connId = null;
    package com.solved.tag.dbtags.connection;
    import javax.servlet.jsp.tagext.TagData;
    import javax.servlet.jsp.tagext.TagExtraInfo;
    import javax.servlet.jsp.tagext.VariableInfo;
    * TagExtraInfo for the connection tag. This
    * TagExtraInfo specifies that the ConnectionTag
    * assigns a java.sql.Connection object to the
    * "id" attribute at the end tag.
    * @author Matt Shannon
    * @see ConnectionTag
    public class ConnectionTEI extends TagExtraInfo {
    public final VariableInfo[] getVariableInfo(TagData data)
    return new VariableInfo[]
    new VariableInfo(
    data.getAttributeString("id"),
    "java.sql.Connection",
    true,
    VariableInfo.AT_END
    data-sources.xml:
    <?xml version="1.0"?>
    <!DOCTYPE data-sources PUBLIC "Orion data-
    sources" "http://xmlns.oracle.com/ias/dtds/data-sources.dtd">
    <data-sources>
    <data-source
    class="oracle.jdbc.pool.OracleConnectionCacheImpl"
    name="jdbc/pool/OracleCache"
    location="jdbc/pool/OracleCache"
    url="jdbc:oracle:thin:@oracle1:1521:pdev"
    >
    <property name="maxLimit" value="15" />
    <property name="cacheScheme" value="2" />
    <property name="user" value="console" />
    <property name="password" value="console" />
    <description>
    This DataSource is using an Oracle-native DataSource Class so as
    to allow Oracle Specific extensions.
    A getConnection() call on this DataSource will return
    oracle.jdbc.driver.OracleConnection.
    The connection returned is a logical connection.
    The caching scheme in place is Fixed Wait. Refer below to
    possible values.
    Dynamic 1
    Fixed Wait 2
    Fixed Return Null 3
    </description>
    </data-source>
    </data-sources>
    many thanks,
    Matt.

    Hi. Show me your pool definition.
    Joe
    Ramamurthy wrote:
    I am using the jsp custom tag library from BEA called sqltags.tld which came with Weblogic 5.1. Currently I am using Weblogic6.1 sp2 on Solaris.
    I have created a Connection Pool for Sybase database using the driver com.sybase.jdbc.SybDriver.
    When I created jsp page to connect to the connection pool using sqltags custom tag library, I am getting the error
    "javax.servlet.jsp.JspException: Failed to write body content
    at weblogic.taglib.sql.ConnectionTag.doAfterBody(ConnectionTag.java:43)
    at jsp_servlet.__hubwcdata._jspService(__sampletest.java:1014)"
    After this message, whenever I try to access the same jsp page I am getting the message
    "javax.servlet.jsp.JspException: Failed to load JDBC driver: weblogic.jdbc.pool.D
    river
    at weblogic.taglib.sql.ConnectionTag.doStartTag(ConnectionTag.java:34)
    at jsp_servlet.__hubwcdata._jspService(__sampletest.java:205)".
    Can you please help me the reason why this problem is happening and how to fix this ?
    This problem doexn't happen consistently. This occurs once in a while.
    I tried to increase Login delay Seconds parameter in the Connection Pool to 15 sec. It didn't help me much.
    Thanks for your help !!!
    Ram

  • Dynamic include in a custom tag, called from a jsp

    Hello, I would like to be able to dynamically include other jsp's from within a custom tag that I create. is this possible?
    in a jsp page i would just write <%@ include file="file.jsp" %> and all would be ok... but if i do an out.println( "<%@ include file=\"file.jsp\" %>" ); inside a custom tag bean then it doesn't work. it just prints out the command to the page as plain text.
    I do understand why this is happening, but can anyone offer me a way around this problem?
    Thanks in advance,
    Randy

    That's actually the same result as you get with a normal include - The method I suggested is a dynamic include similar to the <jsp:include> tag, not the <%@ include %> tag.
    When you use a dynamic include, the included page is compiled and 'invoked' as serarately, and the result is what gets included, not the actual source. To get the behaviour you want would require an include directive (the <%@ include %> tag) which I don't think has an equivalence you can use inside a custom tag.
    What you can do is pass attributes from the tag class like this:
    pageContext.setAttribute(<name>, <object>, pageContext.REQUEST_SCOPE);
    and then remove them after the include using pageContext.removeAttribute.
    I'm not certain, but this implies that if you declare your variables with a <jsp:usebean> tag with request scope, instead of normal Java variable declarations, you should be able to use them in the page included by the custom tag.
    *** in the jsp ***
    <jsp:useBean id="myVar" scope="request" class="java.lang.String" />
    <% myVar = "Something"; %>
    // Now call the tag which uses the pageContext.include() mehtod.
    *** end ***
    *** in the include ***
    <jsp:useBean id="myVar" scope="request" class="java.lang.String" />
    <%= myVar + " something else" %>
    *** end ***
    Let me know if it works.

  • HTMLEditorKit, Custom Tags and CSS???

    I have an editor that will allow the user to insert merge fields. The document is in HTML and the editor supports basic document styling (bold, italics, etc).
    For the merge fields I would like to use either a custom tag or a generic tag like span. Unfortunately, HTMLEditorKit only supports HTML 3.2 (which does not contain the span tag). How can I create a custom tag called "merge"?
    Once I've created my custom tag, will the Cascading Style Sheet support in Java allow something like "merge {color: red}"?
    Any help of suggestions would be greatly appreciated!
    -- John

    Hi John,
    I'm trying to do the same thing (an editor for document containing merge fields...)
    For your first problem, I used the var tag which is not very used but exists in HTML 3.2 !
    And yes: HTMLDocument support CSS
    Since June, I think you've finded a solution
    If you success in creating a custom tag, please explain to me how do you make...
    my e-mail is [email protected]
    Thanks
    Luc

  • Integrating a legacy custom tag with facelets webapp

    Hi
    I have an external custom tag ( a handler that had extended javax.servlet.jsp.tagext.TagSupport ). I am trying to use that custom tag in my .xhtml file(mine is facelets webapp). Please see the xhtml content below
    <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:tGrid="http://java.pershing.com/tGrid">
    <tGrid:gridFields viewname="view1" isDefault="true" fields="Symbol,Quantity,Security Description,Account Type"/>
    </html>
    The problem here, the tag handler class is not getting invoked, i do not get the HTML content from it.
    I understand like we need to add 'taglib.xml' file as below, and register as config files in servlet context param.
    <tag>
    <tag-name>gridFields </tag-name>
    <handler-class>
    xyz.Grid
    </handler-class>
    </tag>
    I have collected the attributes and kept as TagAttribute in Grid handler class..
    But how could i invoke the custom handler class that had implemented TagSupport and start its own life cycle.
    Please help me out.
    Thanks
    -vijay

    Okay. so we cannot use any legacy custom tags and we need to duplicate the code into a new facelets handler class and add into tablig.xml file. is my understanding correct.?
    By the way, JSTL tags like <c:out> <c:if> are being identified by facelets view handler. How this cud have been supported by it?
    Thanks
    -vijay

  • Include external html trough code in a custom tag

    Hi,
    I have a custom tag. The component class (say MyComponentUI) for my custom component extends UIComponentBase.
    I want to include an external html page, which url is formed using the content of an attribute of my tag (for example, the "value" attribute), through the MyComponentUI code.
    Can anyone give me some help ?
    Pietro

    That's actually the same result as you get with a normal include - The method I suggested is a dynamic include similar to the <jsp:include> tag, not the <%@ include %> tag.
    When you use a dynamic include, the included page is compiled and 'invoked' as serarately, and the result is what gets included, not the actual source. To get the behaviour you want would require an include directive (the <%@ include %> tag) which I don't think has an equivalence you can use inside a custom tag.
    What you can do is pass attributes from the tag class like this:
    pageContext.setAttribute(<name>, <object>, pageContext.REQUEST_SCOPE);
    and then remove them after the include using pageContext.removeAttribute.
    I'm not certain, but this implies that if you declare your variables with a <jsp:usebean> tag with request scope, instead of normal Java variable declarations, you should be able to use them in the page included by the custom tag.
    *** in the jsp ***
    <jsp:useBean id="myVar" scope="request" class="java.lang.String" />
    <% myVar = "Something"; %>
    // Now call the tag which uses the pageContext.include() mehtod.
    *** end ***
    *** in the include ***
    <jsp:useBean id="myVar" scope="request" class="java.lang.String" />
    <%= myVar + " something else" %>
    *** end ***
    Let me know if it works.

Maybe you are looking for

  • Receive error message "An error occurred while trying to access the service" when I try to convert a file?

    When I attempt to convert a file, either to PDF or from PDF I receive the error message "An error occurred while trying to access the service" what can I do to resolve?  I already applied updates and attempted to fix?

  • Sony BRAVIA Call failed error message

    I'm trying to use Skype on a Sony BRAVIA TV and with the CMU-BR100 camera installed. I cannot make a video or telephone call to another skype user. I get call failed error message for both video and telephone. Do I need to buy Skype credits to be abl

  • PP - QM: Reversal of the usage decision

    Hi Gurus, We have completed Result Recording using QE51N transaction and Usage decision using QA11. It has posted a stock from QI to Unrestricted use. Now I want to take it back from Unrestricted use to QI. This needs reversal of usage decision (What

  • SCOM and SharePoint 2010 Add-In for Dashboards (Issue)

    I have an environment with SCOM 2007 R2, all working fine. I have installed ans new test server to integrate SCOM and SahrePoint 2010. On this server I have installed Visio 2010 (Yes, I know, never install Visio in a server, but this ins juts for tes

  • Problem using DataSource for JDBC applications

    import javax.sql.*; import java.sql.*; import java.io.*; import java.text.*; import javax.naming.*; public class CreateMovieTables {      //static String driver="COM.cloudscape.core.JDBCDriver";      //static String url="jdbc:cloudscape:";      Strin