Custom Tag doubt

I am trying to use custom tags in my JSP. I have illustrated the simplified version of my problem below. Can anyone tell me how to go about doing it?
Problem definition:
I have a JSP in which I retrieve a hashtable from request object using request.getAttribute() method. I need to display the commodity details present in the Hashtable using custom tags.
Input Hashtable contents(given in Key: Value format)
"Commodity.length": "2"
"Commodity[0].Weight": "34"
"Commodity[1].Weight": "43"
Please note that the above keys are not Java arrays, they are just strings
Required JSP format
<gan:array name = "Commodity">
<table>
  <tr>
  <input type='text'
         name='<gan:getFullNameForItem name="Weight" />'
         value='<gan:getValueForItem name="Weight" />'   />
  </tr>
</table>
</gan:array>
Desired HTML output:
<table>
  <tr>
  <input type='text'
         name='Commodity[0].Weight'
         value='34'  />
  <input type='text'
         name='Commodity[1].Weight'
         value='43'  />
  </tr>
</table>
My question:
How can I go about implementing the tags starting with "gan:"?
Please note that there can be nested gan:array tags.

Check out the following few resources for a quick reference which you may find useful:
1)http://developer.java.sun.com/developer/technicalArticles/xml/WebAppDev3/
2)http://java.sun.com/webservices/docs/ea1/tutorial/doc/JSPTags6.html#66793
3)http://www-106.ibm.com/developerworks/library/j-taglib/
Rommel Sharma.

Similar Messages

  • 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

  • Why doesn't my custom tag work?

    First, my backend database is MS Access. Nothing I can do about that, unfortunately.
    I have defined three custom tags (no body, no attributes) to display report information from my project tracking/metrics Access database:
    <prefix:showProjectInfo />
    <prefix:showProjectTeam />
    <prefix:showProjectHistory />
    In my JSP, the first tag I use, <prefix:showProjectInfo />, works perfectly. However, <prefix:showProjectTeam /> gives no output.
    First, here is the tld file that defines the tags (report.tld):
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE taglib
            PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
            "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
    <taglib>
        <tlib-version>1.0</tlib-version>
        <jsp-version>1.2</jsp-version>
        <short-name>report</short-name>
        <uri>/report</uri>   
        <!-- Forte4J_TLDX:  This comment contains code generation information. Do not delete.
        <tldx>
            <tagHandlerGenerationRoot>classes</tagHandlerGenerationRoot>
        </tldx>
        -->
        <!-- A validator verifies that the tags are used correctly at JSP
             translation time. Validator entries look like this:
          <validator>
              <validator-class>com.mycompany.TagLibValidator</validator-class>
              <init-param>
                 <param-name>parameter</param-name>
                 <param-value>value</param-value>
           </init-param>
          </validator>
       -->
       <!-- A tag library can register Servlet Context event listeners in
            case it needs to react to such events. Listener entries look
            like this:
         <listener>
             <listener-class>com.mycompany.TagLibListener</listener-class>
         </listener>
       -->
       <tag>
            <name>showProjectInfo</name>
            <tag-class>mil.usaf.rad.metrics.report.showProjectInfoTag</tag-class>
            <body-content>empty</body-content>
            <description>Shows the basic project information</description>       
       </tag>
       <tag>
            <name>showProjectTeam</name>
            <tag-class>mil.usaf.rad.metrics.report.showProjectTeamTag</tag-class>
            <body-content>empty</body-content>
       </tag>
       <tag>
            <name>showProjectHistory</name>
            <tag-class>mil.usaf.rad.metrics.report.showProjectHistoryTag</tag-class>
            <body-content>empty</body-content>
       </tag>
    </taglib>Next, here is the relevant section of web.xml that defines this taglib:
      <taglib>
            <taglib-uri>/WEB-INF/report.tld</taglib-uri>
            <taglib-location>/WEB-INF/report.tld</taglib-location>
      </taglib>Next, the code for showProjectTeamTag.java:
    * showProjectTeam.java
    * Created on March 9, 2005, 10:46 AM
    package mil.usaf.rad.metrics.report;
    import java.io.*;
    import java.sql.*;
    import java.lang.Integer;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    * @author  jason.ferguson
    public class showProjectTeamTag extends TagSupport
        public showProjectTeamTag()
            super();
        public int doAfterBody() throws JspException
            HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
            int pr_id = Integer.parseInt(req.getParameter("pr_id"));
            JspWriter out = pageContext.getOut();
            Connection conn = null;
            Statement stmt = null;
            ResultSet rs = null;
            try
               out.print("test");
               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
               conn = DriverManager.getConnection("jdbc:odbc:Metrics");
            catch (Exception e)
                throw new JspException(e.getMessage());
            String queryGetTeam = "SELECT Projects.pr_id, Accounts.name AS Name, Sum(Schedule.hours) AS SumOfhours FROM tblTAAccounts AS Accounts INNER JOIN ((tblTAScheduleEntries AS Schedule INNER JOIN tblProjectRelease AS ProjectRelease ON Schedule.projectID = ProjectRelease.tblFKTimeAccntProject) INNER JOIN tblPMProjects AS Projects ON ProjectRelease.Release_ID = Projects.pr_id) ON Accounts.accountID = Schedule.accountID WHERE Projects.pr_id=" + pr_id + " GROUP BY Projects.pr_id, Accounts.name, ProjectRelease.Release_number, Projects.Project_name";
            try
                out.print(queryGetTeam);
                stmt = conn.createStatement();
                rs = stmt.executeQuery(queryGetTeam);
                if (rs == null)
                    out.print("No Results!");
                out.print("<table>\n");
                out.print("<tr>\n");
                out.print("<th>Name</th>\n");
                out.print("<th>Total Hours</th>\n");
                out.print("</tr>\n");
                while(rs.next())
                    out.print("<tr>\n");
                    out.print("<td>" + rs.getString("Name") + "</td>\n");
                    out.print("<td>" + rs.getInt("SumOfhours") + "</td>\n");
                    out.print("</tr>\n");
                out.print("</table>\n");
                rs.close();
                stmt.close();
                conn.close();
            catch (Exception e)
                throw new JspException(e.getMessage());
            return SKIP_BODY;
    }Finally, projectdetail.jsp, where the tag is called:
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@page import="java.sql.*" %>
    <%@page import="java.lang.Integer" %>
    <%@taglib uri="/WEB-INF/report.tld" prefix="report" %>
    <html>
    <head><title>Project Detail</title></head>
    <body>
    <h1 align="center">Project Status</h1>
    <h3>Project Description</h3>
    <report:showProjectInfo />
    <h3>Team Members</h3>
    <report:showProjectTeam />
    </body>
    </html>The first tag, <report:showProjectInfo />, works fine. However, I get no output whatsoever when the system encounters <report:showProjectTeam />. I am a relative newbie at this, so any help is appreciated.
    Jason

    It doesnt seem to matter if the code is in doStartTag(), doEndTag(), orr any of the other functions.
    I also put, as the first item in the function:
    System.out.println("TEST");Nothing.
    Just as an aside, here is the code for the <prefix:showProjectInfo />. Maybe I made a mistake in it? I closed the resultset and connection...
    import java.io.*;
    import java.sql.*;
    import java.lang.Integer;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    * @author  jason.ferguson
    public class showProjectInfoTag extends BodyTagSupport
        public int doEndTag() throws JspException
            HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
            int pr_id = Integer.parseInt(req.getParameter("pr_id"));
            JspWriter out = pageContext.getOut();
            Connection conn = null;
            Statement stmt = null;
            ResultSet rs = null;
            try
               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                conn = DriverManager.getConnection("jdbc:odbc:Metrics");
            catch (Exception e)
                throw new JspException(e.getMessage());
            String queryProjectInfo = "SELECT * FROM tblPMProjects WHERE pr_id=" + pr_id;
            try
                stmt = conn.createStatement();
                rs = stmt.executeQuery(queryProjectInfo);
                while (rs.next())
                    out.print("<table border=\"1\" style=\"border-collapse:collapse\">\n");
                    out.print("<tr>\n");
                    out.print("<td><b>Project Name:</b>" + rs.getString("Project_name") + "</td>\n");
                    out.print("<td align=\"right\"><b>RAD Number:</b>" + rs.getString("tblProjectNumber") + "</td>\n");
                    out.print("</tr>\n");
                    out.print("<tr>\n");
                    out.print("<td>Project description: " + rs.getString("Project_description") + "</td>\n");
                    out.print("</tr>\n");
                    out.print("<tr>\n");
                    out.print("<td>Customer: " + rs.getString("Customer_POC") + "</td>");
                    out.print("<tr>\n");
                    out.print("<tr>\n");
                    out.print("<td>Customer Unit: " + rs.getString("Customer_OFC") + "</td>\n");
                    out.print("</tr>\n");
                    out.print("<tr>\n");
                    out.print("<td>Customer Phone: " + rs.getString("Customer_phone") + "</td>\n");
                    out.print("</tr>\n");
                    out.print("</table>\n");
                    rs.close();
                    stmt.close();
                    conn.close();
            catch (Exception e)
                throw new JspException(e.getMessage());
            finally
                //conn.close();
            return SKIP_BODY;

  • Weblogic Commerce Server 3.5 runtime failure in custom tag

    An error occurred:
    javax.servlet.ServletException: runtime failure in custom tag 'process'
         at jsp_compiled._tools._property._propset_create._jspService(_propset_create.java:641)
         at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:208)
         at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:149)
         at com.beasys.commerce.foundation.flow.ServletDestinationHandler.handleDestination(ServletDestinationHandler.java:51)
         at com.beasys.commerce.foundation.flow.FlowManager.service(FlowManager.java:540)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:208)
         at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:1127)
         at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1529)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)

    I just started getting this error after a year in production environment without any problems. Did you every find out what caused this or better yet how to prevent this?
              Dan.
              

  • 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

  • Is possible to write a custom tag inside another custom tag ??

    Hi
    I�m trying to reduce the time needed to code mi app presentation layer, it uses some custom tags with certain configuration, i would like to know if its possible to do something like this inside my custom tag doAfterBody().
    public int doAfterBody() throws JspException {
              JspWriter writer=bodyContent.getEnclosingWriter();
              try {
                   writer.print("<customTag:myAnotherTag someEspecificConfigurationParams="someEspecificValues"/>");
              } catch (IOException e) {
                   pageContext.getServletContext().log("Error: "+e.getMessage());
              }return SKIP_BODY;
         }The goal is to simplify the jsp code because the configuration params for the custom tags (css styles and similar) are allways the same.
    That don�t work, it simply prints <customTag:myAnotherTag/> in screen but the tag is not evaluated, i�ve tried too something like
    public int doAfterBody() throws JspException {
              if (repeat) {
                   JspWriter writer = bodyContent.getEnclosingWriter();
                   try {
                        writer.print("<customTag:myAnotherTag/>");
                   } catch (IOException e) {
                        pageContext.getServletContext().log("Error: " + e.getMessage());
                   repeat = false;
                   return EVAL_BODY_AGAIN;
              return SKIP_BODY;
         }And it doesn�t worked worked. Maybe using the taghandler classes and calls to the doAfterBody could make it work, but when you need to nest tags it could be a little hell of coupling calls, so before doing it i would like to know if what i want is possible. After reading some books i tought it could work because the stack of out objects, but i can�t make it work.
    Another idea is to inherit from tagHandler and override some properties in the tags, but i don�t like the idea to much.
    So, can anyone help me??
    Thanks.

    You cannot do that and I have listed out the reason and a possible solution in this post http://forum.java.sun.com/thread.jspa?threadID=697243 from yesterday.
    cheers,
    ram.

  • How to prepare Custom tag with scope as  session  like Struts tag

    Hi
    All Struts tags having the feature of Automatic Scoping.
    Automatic Scoping: Struts tags check all contexts (namely page, request, session, application) and use the first instance found. Developers do not have to explicitly "retrieve" objects from a particular scope. They may, however, specify a context.
    same as like struts tag I want to preapre 'select custom tag'.which will retrieve its previous selected value automatically and display.And one important thing is I dont want to set the selected value of custom tag in session expicitly.I mean the custom tag it self should take care to set the session vale and retrieve the sesion value and display like Struts tag . For struts select tag we wont set any selected value in session though it will retrieve the previous value and display when scope of form = session
    regards
    jagan

    Hi
    All Struts tags having the feature of Automatic Scoping.
    Automatic Scoping: Struts tags check all contexts (namely page, request, session, application) and use the first instance found. Developers do not have to explicitly "retrieve" objects from a particular scope. They may, however, specify a context.
    same as like struts tag I want to preapre 'select custom tag'.which will retrieve its previous selected value automatically and display.And one important thing is I dont want to set the selected value of custom tag in session expicitly.I mean the custom tag it self should take care to set the session vale and retrieve the sesion value and display like Struts tag . For struts select tag we wont set any selected value in session though it will retrieve the previous value and display when scope of form = session
    regards
    jagan

  • Make new custom tag in A2

    Good evening,
    I'm trying to add a custom tag to an image in Aperture 2.0. I've looked all over the internet and find no examples what so ever of AS and Aperture 2.0.
    I have a few guesses that produce one of two different errors - but no idea how to actually make this work. Any ideas ?
    tell application "Aperture"
    copy selection to theSel
    repeat with curImg in theSel
    class of curImg
    --image version
    -- make new custom tag at curImg with properties {name:"NewTag", value:"New Tag's Value"}
    -- set aNewTag to make new custom tag with properties {name:"NewTag", value:"New Tag's Value"}
    -- Aperture got an error: Can’t make or move that element into that container.
    -- make new custom tag at end of curImg with properties {name:"NewTag", value:"New Tag's Value"}
    -- make new custom tag at end of (curImg) with properties {name:"NewTag", value:"New Tag's Value"}
    -- make new custom tag at end of custom tags of curImg with properties {name:"NewTag", value:"New Tag's Value"}
    -- make new custom tag at end of curImg's custom tags with properties {name:"NewTag", value:"New Tag's Value"}
    --Aperture got an error: Can’t make application "Aperture" into type specifier.
    end repeat
    end tell

    If I recall, it was done because how tags were to be handled in 1.2 was very different from 1.1 and it was felt that developers shouldn't rely on implementation specific classes (unless they were SPI) for several other reasons (application portability being the big one here).
    If it's felt that this was the wrong decision, please feel free to log an issue [1] against the RI (to date, no one has).
    As to the 'borked' dependency URLs, please log an issue [1] if you find these. We have nightly builds going that work from a clean workspace and checking today's result, it seems ok.
    [1] https://javaserverfaces.dev.java.net/issues

  • Passing Javascript Enabled or Disabled value in a custom tag

    Hi,
    In my JSP I am using a custom tag.
    This custom tag is having one attribute called status(whose value will be jsenabled means true or jsdisabled means false) depending on the browser's javascript enabled or disabled
    How can i find the value of javascript enabled or javascript disabled and set the value of the attribute status in my jsp.
    This is the custom tag
    <t:tab summary="tabs" url="/services/eservicepac/registrationprocess/process.wss" tabNames='<%=tabList%>' currentTab="<%=currentTab%>" zone="WWW_ZONE" fetchText="false" status=" "
    </t:tab>
    The value of this attribute status=" " should be the value of jsenabled or disabled.
    Since the user can visit any page at any time, the jsenabled value is not maintained in session or request, so i can't take from session or request also.
    As this is urgent,
    --I am expecting the reply                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi Merlin,
    In addition to what was written above, you must make sure that you tell your web application to run as a JSP 2.0 web application.
    You do this by defining your web.xml a little differently. Like this at the top:
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd">
    That should be what you need to get it working correctly.
    Damian Sutton

  • How to create a custom tag for a custom converter

    In Jdeveloper 11g, I have a project where I have created a custom converter class that impements the javax.faces.convert.Converter class. I have registered the converter with an id in the faces-config.xml file of the project, and the converter works fine by using the <f:converter type="myconverter"> tag. However, the custom converter has a field which I would like to set from the tag itself. Hence, I would like to add an attribute to <f:converter> tag if possible or create a custom tag that has the attribute.
    I have done some reserach and I found that a custom tag can be implemented: I need to create a class which extends from the ConverterTag class or javax.faces.webapp.ConverterElTag class, which I did, but I also need to create ".tld" (tag library) file which defines the tag itself.
    The part about creating the ".tld" file and registring the new tag is what I'm not sure how to do.
    Does someone know how to do this?
    thank you

    Hi frank,
    that's a good document, and it explains how to make a custom converter. I already created the custom converter, it converts a number to any currency pattern. I know java already has a currency converter, but it doesn't support Rupee currency format, and I need that format.
    My converter works, but I would like to pass the pattern of the format through an attribute in a tag. Since f:converter doesn't seem to support that, I created a custom tag which uses my converter, and it enables me to pass a pattern to the converter.
    All of that works, but I need to be able to pass the pattern as an EL expression, and it's not evaluating the expression before passing it to the converter. It just passes the whole expression as a string. I'm thinking It may be something I'm doing wrong.
    this is the tag library definition file:
    <!DOCTYPE taglib
    PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
    "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
    <taglib>
    <tlib-version>1.2</tlib-version>
    <jsp-version>2.1</jsp-version>
    <short-name>custom</short-name>
    <uri>custom-currency-converter</uri>
    <description>
    custom currency custom tag library
    </description>
    <tag>
    <name>CurrencyConverter</name>
    <tag-class>
    converter.Tag.CurrencyConverterTag
    </tag-class>
    <body-content>JSP</body-content>
    <attribute>
    <name>pattern</name>
    <type>java.util.String</type>
    <required>true</required>
    <rtexprvalue>true</rtexprvalue>
    </attribute>
    </tag>
    </taglib>
    Edited by: Abraham Ciokler on Feb 4, 2011 11:20 AM

  • How To create a custom tag in jsf

    I'm trying to create a custom tag in jsf.what should be the approach to create it.it would be better if somebody will explain me from the skretch.

    There's a decent tutorial here, Priyo:
    http://www.exadel.com/tutorial/jsf/HowToWriteYourOwnJSFComponents.pdf
    Hope it helps,
    Illu

  • Simple question about custom tags really easy!!

    I am trying to make my own custom tags, so far i have created simple one that have i use for heading or to set the page layout for a jsp page, My question is I want to make a custom tag with a body , with a start and end tag can anybody give a simple example of a custom tag which has a body.
    I do not mean write me a tag i mean what could a tag with a body be used for? Can you give me some example of what a tag of this kind could do?

    Thanks having read that and some other pages i have another question:
    would it be possible to put the following code into a custom tag so that i can pass in a list and have it output it to a table?
    <TABLE >
    <% 
    out.println("<TABLE >\n" +
                    "<TR BGCOLOR=\"#FFDDAA\">\n" +
                    "  <TH>ID Number\n" +
                    "  <TH>Artist\n"
    Iterator it = pricePassed.getpricePassed().iterator();
    while( it.hasNext() ){
       MySite.VideoBean vids = (MySite.VideoBean) it.next();
       out.println( "<TR>\n" +
                   "<TD><Center><B>" + vids.getRecId() + "</TD>" +
                    "<TD><Center><B>" + vids.getArtist() + "</TD>"
    </TD></TR>\n" );
    %></TABLE>At the moment i use the above in a jsp to put data into a table, would it be a massive task to undertake to put into a custom tag?

  • Question about custom tags

    Hi All,
    Please tell me what is differnce between javabean and custom tags.
    thank you.

    Javabean is a data object (or a data holder) whose properties can be accessed using getters, setters - ex getName() and setName()
    JSP custom tags are merely Java classes that implement special interfaces (Tag interface). Once they are developed and deployed, their actions can be called from your HTML using XML syntax. Refer the article http://java.sun.com/developer/technicalArticles/xml/WebAppDev3/
    Cheers,
    Janesh

  • Error in running custom tag

    Hi
    I am new in jsp?s custom tag development and trying to run it's example with jakarta-tomcat-4.1.30. I have hello.jsp
    <%@ taglib uri="/WEB-INF/mytaglib.tld" prefix="first" %>
    <HTML>
    <HEAD> <TITLE>hELLO tAG</TITLE></HEAD>
    <BODY bgcolor="#ffffcc"><B>My first tag prints</B>
    <first:hello/></HTML>
    and mytaglib.tld as
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE taglib PUBLIC "-//Sun MicroSystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
    <taglib>
    <tlibversion>1.0</tlibversion>
    <jspversion>1.2</jspversion>
    <shortname></shortname>
    <uri></uri>
    <info>A simple tag library for the example</info>
    <tag>
    <name>hello</name>
    <tagclass>HelloTag</tagclass>
    <bodycontent>empty</bodycontent>
    <info></info>
    </tag>
    </taglib>
    and HelloTag.java as
    import javax.servlet.jsp.JspException;
    import javax.servlet.jsp.PageContext;
    import javax.servlet.jsp.tagext.Tag;
    public class HelloTag implements Tag {
         private PageContext pageContext;
         private Tag parent;
         public HelloTag() {
              super();     }
         public void setPageContext(PageContext arg0) {
              this.pageContext = arg0;}
         public void setParent(Tag arg0) {
              this.parent = arg0;}
         public Tag getParent() {
              return parent;}
         public int doStartTag() throws JspException {
              try{
                   pageContext.getOut().print("This is my first Tag");
              }catch(Exception e){throw new JspException("Error);}
              return SKIP_PAGE;     }
         public int doEndTag() throws JspException {
              return SKIP_PAGE;}
         public void release() {     }
    I am getting following error
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: /hello.jsp(7,0) Unable to load class hello
         at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:94)
         at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:428)
         at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:219)
         at org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:712)
         at org.apache.jasper.compiler.Parser.parseElements(Parser.java:804)
         at org.apache.jasper.compiler.Parser.parse(Parser.java:122)
         at org.apache.jasper.compiler.ParserController.parse(ParserController.java:199)
         at org.apache.jasper.compiler.ParserController.parse(ParserController.java:153)
         at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:227)
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:369)
         at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:473)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:190)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    Can anyone help me in running this example.

    an uri is not an url,
    in your web.xml you should have something like
    <taglib>
    <taglib-uri>http://yourtaglib/taglib</taglib-uri>
    <taglib-location>/WEB-INF/yourtaglibtld</taglib-location>
    </taglib>
    that uri should be same as in the tld.file and same as in the <%@ taglib tag

  • Problem Calling Query in Custom Tag

    I am using this code to call a custom tag called
    broadcast.cfm
    <cf_broadcast query="fe" orgID = "4">
    The query fe is an included file on my site and is available
    to the page I'm calling the custom tag from.
    In the custom tag I am referencing the query like:
    <cfloop query="#attributes.query#">
    but I keep getting this error:
    "The value of the attribute query, which is currently "fe",
    is invalid. "
    I must be missing something really simple here but can't
    figure out what.

    quote:
    Originally posted by:
    -==cfSearching==-
    rdk8487 wrote:
    > In the custom tag I am referencing the query like:
    > <cfloop query="#attributes.query#">
    > but I keep getting this error:
    > "The value of the attribute query, which is currently
    "fe", is invalid. "
    It is a scoping problem. The query is defined in the calling
    page. To access it by name, within the custom tag, use the "caller"
    scope.
    <cfloop query="caller.#attributes.nameOfTheQuery#">
    If the query object is passed to the custom tag via an
    attribute you shouldn't need the caller scope. See attached sample.

Maybe you are looking for