JSF custom tag body content problem

Hi, I'm having some problem with a custom tag I built, but the body of the tag content is not rendered correctly.
I have:<foo:bar>
    <ul>
        <li>blah</li>
        <li>blah</li>
    </ul>
</foo:bar>
</pre>But the rendered html source look like this:    <ul>
        <li>blah</li>
        <li>blah</li>
    </ul>
<!-- beging foo tag -->
<!-- end foo tag -->The <ul> tags are supposed to be inside of the <!-- begin foo --> & <!-- end foo -->. I've declared in TLD it has JSP content. I've compared to the J2EE tutorial and corejsp book again and again, couldn't figure where I went wrong. So, am I missing something?
Thanks a lot.

Use <f:verbatim> around the non-jsf content.
I.e.<foo:bar>
<f:verbatim>
    <ul>
        <li>blah</li>
        <li>blah</li>
    </ul>
</f:verbatim>
</foo:bar>--
Sergey : jsfTutorials.net

Similar Messages

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

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

  • Custom tags in jsp - problems with import in java pgm

    Hi,
    I am new to JSP and am facing some problems.
    I am trying to compile the foll. java program and it is giving an error saying 1."Package javax.servlet.jsp does not exist", 2."Package javax.servlet.jsp.tagext does not exist".
    I am using 1.j2sdk1.4.1_02, 2.j2sdkee1.3.1,and 3.Tomcat 4.1
    My java_home=C:\j2sdk1.4.1_02
    j2ee_home=C:\j2sdkee1.3.1
    path=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;c:\j2sdkee1.3.1\bin;c:\j2sdk1.4.1_02\bin;c:\j2sdkee1.3.1\doc\api;c:\jakarta-ant-1.5.1\bin
    classpath=c:\j2sdkee1.3.1\bin;c:\j2sdk1.4.1_02\bin;c:\j2sdkee1.3.1\doc\api
    can anybody help me with it?
    Regards,
    newtojsp
    import java.io.IOException;
    import java.util.Date;
    import doc.api.javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    public class TestTag extends TagSupport
         public int doStartTag () throws JSPTagException
              String dateString = new Date().toString ();
              try
                   JspWriter out = page.context.getOut ();
                   out.println ("Welcome to the Loan Dept" + " <br>");
                   out.println ("Today is:" + dateString + "<br>");
                   return SKIP_BODY;
              } catch (IOException ee)
                   throw JspTagException ("Error Encountered");
         public int doEndTag () throws JSPTagException
              return EVAL_PAGE;

    I got the solution for this.
    Thanks
    Newtojsp

  • Custom tag error

    I'm tring to create a new JSF custom tag. my custom tag inherits from another custom tag called tab.
    the tld look like this :
    <taglib>
    <tlib-version>1.0</tlib-version>
         <jsp-version>1.2</jsp-version>
    <short-name>actab</short-name>
    <uri>http://jsftutorials.com/</uri>
    <tag>
    <name>actab</name>
    <tag-class>com.ca.accesscontrol.tabs.monolithic.ACTabTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
              <name>include</name>
         </attribute>
    <attribute>
         <name>name</name>
         <required>true</required>
         <rtexprvalue>false</rtexprvalue>
         <description>Tab name to be displayed on this tab.</description>
         </attribute>
    <attribute>
              <name>id</name>
         </attribute>     
    </tag>
    </taglib>
    I'm tring to use the custom tag in the jsp, when I specify the attrbute name I get the following error:
    monolithic.jsp(14,13) Attribute name invalid according to the specified TLD
    when I remove the name attribute from the jsp I get the following error :
    monolithic.jsp(13,10) According to the TLD attribute name is mandatory for tag actab.
    does anyone have an idea about what the problem is ?

    a bit more info required I think.
    Is there more to that exception than you posted - coming from your code?
    Maybe you can put try/catch code in your Tag source file to catch and print any exceptions that occur.
    Beans property conversion would indicate that it has translating one type to another.
    What attributes does this tag take. Should width be an integer - and 96% causes it an error?
    Lets see the tld file, and maybe some basic source?

  • [Custom Tags] Dynamic Variable Name // Spring MVC

    I am having a problem with a tag,
    i try to make a dynamic select tag that is reuseable, the problem is that my spring controller generates a model where i can access the list information for a select and that i have to pass this to the dynamic tag, the model could have different name, so it could be ${listitemsa} ${listitemsb} ${listitemsc} and i want to pass this list to my custom tag.
    i tried the following, but the problem is that the var is passed as a string and not the list, does anybody know how to do this?
    <tag:formfield-selectbox name="listA" path="prototypeForm.selectionA" list="${listitemsa} " />
    <tag:formfield-selectbox name="listB" path="prototypeForm.selectionB" list="${listitemsb} " />
    <tag:formfield-selectbox name="listC" path="prototypeForm.selectionC" list="${listitemsc} " />     
    <%@ tag body-content="scriptless" %>
    <%@ attribute name="name" required="true" %>
    <%@ attribute name="path" required="true" %>
    <%@ attribute name="list" required="false" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %> 
    <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
    <spring:bind path="${path}">
         <c:if test="${status.error}">
              <span class="error">
                   <c:forEach items="${status.errorMessages}" var="error">
                        <c:out value="${error}"/>
                   </c:forEach>
              </span><br />
         </c:if>
         <label for="<c:out value="${status.expression}"/>">${name}: </label>
         <form:select path="${path}">
              <form:option value="-1" label="--Please Select--" />
              <form:options items="${list}" />
         </form:select>
    </spring:bind>

    I've sorted it. Here's the solution for anybody experiencing the same problem.
    The problem is with switching from Java 1.2.1 to Java 1.3.0_02. Custom tags are (as of the JSP 1.1 spec) JavaBean compnents, and the Introspector appears to work differently in different Java versions.
    Consider this example:
    public void setAbc(String abc){}
    public boolean getAbc(){}Since the setter method takes a String and the finder method returns a boolean, the 1.2 Introspector takes the property type to be String, and returns null as the finder name. Java 1.3 (I haven't tested this explicitely, but this is what seems to be happening), returns null for both the setter name and the finder name (Probably a better way to do it, but breaks old code).
    We've rolled back to Java 1.2 and everything works again. It looks to me like the best way to fix the problem for 1.3 is to write custom BeanInfo classes for each JSP custom tag (Can anybody recommend a good JavaBeans book?). I don't yet know what will happen when you have multiple setter methods with different parameter types??? - something I've always found useful in custom tags.
    You don't get the problem on some JSP engines that don't use the Introspector (apparently JRun just puts the method name in the code and lets it fail at runtime if it doesn't exist, whereas apache and iPlanet check the methods exist at compile time).
    Here's where I got most of the answers from:
    http://groups.google.com/groups?hl=en&safe=off&ic=1&th=9330b85b1867cc7,3&seekm=8rnl24%24ef1%241%40nnrp1.deja.com#p
    http://groups.google.com/groups?hl=en&safe=off&ic=1&th=edd3053ac670ff5b,8&seekm=D8E32A666B62F7BD0076240185256A16.0073785185256A15%40webforums#p
    http://groups.google.com/groups?hl=en&safe=off&ic=1&th=7b5480449150ea26,3&seekm=3B2FA8C3.3F14A9F3%40switzerland.org#p

  • Custom tag SetProperty: Mandatory attribute property missing

    Ok, first some code. Here's the contents of my displayCollection.tag:
    <%@ tag body-content="scriptless" import="com.serco.inquire.*" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ attribute name="mgr" required="true" %>
    <jsp:useBean id="irc" scope="session" class="com.serco.inquire.irCollection">
      <jsp:setProperty name="mgrid" value="${mgr}" />
    </jsp:useBean>
    ${irc.mgrid}Here's the JSP I'm calling it from (myq.jsp):
    <%@page language="java" import="java.util.*,com.serco.inquire.*" %>
    <%@ taglib prefix="inq" tagdir="/WEB-INF/tags" %>
    <inq:displayCollection mgr="Chris Novish" />Here's the java class for irCollection (used in the tag file):
    package com.serco.inquire;
    import java.sql.*;
    import java.util.*;
    public class irCollection {
         public String mgrid;
         public irCollection() {
              super();
         public void setMgrid(String datum) {
              this.mgrid = datum;
         public String getMgrid() {
              return this.mgrid;
    }And finally, here's the error I get when i try to run myq.jsp:
    org.apache.jasper.JasperException: /WEB-INF/tags/displayCollection.tag(7,2) SetProperty: Mandatory attribute property missing     org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:41)
         org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
         org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:198)
         org.apache.jasper.compiler.JspUtil.checkAttributes(JspUtil.java:174)
         org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:595)
         org.apache.jasper.compiler.Node$SetProperty.accept(Node.java:1150)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
         org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
         org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:647)
         org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1182)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
         org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
         org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
         org.apache.jasper.compiler.Node$Root.accept(Node.java:475)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
         org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1789)
         org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:216)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:372)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:352)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:339)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:594)
         org.apache.jasper.servlet.JspServletWrapper.loadTagFile(JspServletWrapper.java:231)
         org.apache.jasper.compiler.TagFileProcessor.loadTagFile(TagFileProcessor.java:577)
         org.apache.jasper.compiler.TagFileProcessor.access$000(TagFileProcessor.java:48)
         org.apache.jasper.compiler.TagFileProcessor$TagFileLoaderVisitor.visit(TagFileProcessor.java:642)
         org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1539)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
         org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
         org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
         org.apache.jasper.compiler.Node$Root.accept(Node.java:475)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
         org.apache.jasper.compiler.TagFileProcessor.loadTagFiles(TagFileProcessor.java:660)
         org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:228)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:372)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:352)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:339)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:594)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:344)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:722)>
    as far as I can tell, the attribute mgr is set in myq.jsp when it invokes displayCollection.tag, and displayCOllection.tag's only attribute (required) is mgr. so uhm... what do I misunderstand?

    Nick,
    Thanks for your help.
    But I also face another problem that is
    "unable to load class com.jguru.FormBean" when I tried to call another jsp.
    Here are my code :
    package com.jguru;
    public class FormBean {
    private String LName;
    private String FName;
    private String Passwd;
    private String Tel;
    private String Title;
    private String Dept;
    private String Email;
    private String Accesstype;
    public FormBean() {
    LName="";
    FName="";
    Passwd="";
    Tel="";
    Title="";
    Dept="";
    Email="";
    Accesstype="";
    public String getLName() {
    return LName;
    public String getFName() {
    return FName;
    public String getPasswd() {
    return Passwd;
    public String getTel() {
    return Tel;
    public String getTitle() {
    return Title;
    public String getDept() {
    return Dept;
    public String getEmail() {
    return Email;
    public String getAccesstype() {
    return Accesstype;
    public void setLName(String x) {
    LName = x;
    public void setFName(String x) {
    FName = x;
    public void setPasswd(String x) {
    Passwd = x;
    public void setTel(String x) {
    Tel = x;
    public void setTitle(String x) {
    Title = x;
    public void setDept(String x) {
    Dept = x;
    public void setEmail(String x) {
    Email = x;
    public void setAccesstype(String x) {
    Accesstype = x;
    Thanks.

  • Unable to recognise BigDecimal as Null in Custom tag

    I have written a tag for displaying monetary values which should display '-' if value is null but it always renders null values as 0.00
    <%@ tag body-content="empty" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 
    <%@ attribute name="value" required="true" type="java.math.BigDecimal" %>
    <c:choose>
      <c:when test="${empty value}">-</c:when>
      <c:otherwise>  
        <fmt:formatNumber value="${value}" groupingUsed="true" minFractionDigits="${2}" maxFractionDigits="${2}"/>
      </c:otherwise> 
    </c:choose>
    <c:if test="${empty val[column.prop]}">NULL</c:if>                                                    
    <mytag:fmtmoney value="${val[column.prop]}"/>First line just put in as a test
    should display NULL- but displays NULL0.00

    Ok I worked out what was happening but to be seems counter inuitive, the value being passed to the tag comes froma BigDecimal variable but if it is null it has no type. This null gets passed to the tag and the ExpressionLanguage Coercion rules convert it to zero, so in my tag cant differentiate between zero and null.
    If I change the type of the attribute to a String it works because nulls get converted to empty String and ${empty var} returns true for empty Strings.
    If I changed the type to a user defined class it works because user defined classes keep nulls as nulls.

  • Possible to aggregate multiple JSF custom actions into a single action?

    I'm wondering if it's possible to aggregate multiple JSF custom actions into a single action? For example, I have a JSF custom tag/renderer named selectOneMenuStateAbbreviation that displays a drop down list of state abbreviations. This tag allows a user to select a state abbrevation from the list.
    What I want to do is create another custom tag/renderer and call it inputAddress. The inputAddress tag, will consist of text boxes for street address, city, and zip code. I want to make it so that the state abbreviation custom tag that I already wrote is imbedded in this tag/renderer as well.
    Does anyone know if this is possible? Or, would I have to just duplicate the code that I already have in my other custom action?

    I would assume so, but, I don't know how. Can I do it using just tags and renderers, or, would I need to create a custom UI component as well? One tag would have to be a child of the other correct? I don't know how to do this in Java code. Does anyone know of example code that shows how to do this?
    Jon

  • How to create custom tags in my own folder..(It is very important to know)

    Hi developers,
    I am try to develop custom tags, But i am fail. I take support of internet. I read some documentations to develop custom tags. I can understand everything to develop custom tags . My problem is where to place taghandler,tld and jsp files in tomcat. Could you please guide me how develop custom tags in tomcat. I try to wax. Please guide me.
    Thanking you.
    with regards
    sure...:)-

    You'll have something like
    tomcat/webapps/mysite
    where 'mysite' is the webapp root.
    Then
    mysite/* - holds JSP (in root directory or any subdirectory except WEB-INF)
    mysite/WEB-INF - holds TLDs
    mysite/WEB-INF/classes - holds non-jar class files
    mysite/WEB-INF/lib - holds the jar file containing the custom tag java code
    You can put java classes in either WEB-INF/classes (for *.class files) or WEB-INF/lib (for *.jar files), doesn't matter which.

  • JSF dynamic include and custom tag

    Anybody has experience to enclude custom tags between <f:verbatim> </f:verbatim> ? The custom code embeded this tags won't work, my code as below:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <%-- jsf:pagecode language="java" location="/JavaSource/pagecode/jsp/Server_request.java" --%><%-- /jsf:pagecode --%>
    <%@taglib uri="http://www.ibm.com/jsf/html_extended" prefix="hx"%>
    <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    <%@taglib uri="/WEB-INF/mytaglib.tld" prefix="first" %>
    <HTML>
    <HEAD>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
         pageEncoding="ISO-8859-1"%>
    <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <META name="GENERATOR" content="IBM Software Development Platform">
    <META http-equiv="Content-Style-Type" content="text/css">
    <LINK href="../theme/Master.css" rel="stylesheet"
         type="text/css">
    <TITLE>server_request.jsp</TITLE>
    <LINK rel="stylesheet" type="text/css" href="../theme/stylesheet.css"
         title="Style">
    </HEAD>
    <f:view>
         <BODY><hx:scriptCollector id="scriptCollector1">
         <P><hx:outputLinkEx styleClass="outputLinkEx" value="header"
                   id="linkEx1">
                   <h:outputText id="text1" styleClass="outputText" value="Header"></h:outputText>
              </hx:outputLinkEx><BR></P>
    <jsp:include page="server_req.jsp"/>
              <hx:outputLinkEx styleClass="outputLinkEx" value="Footer" id="linkEx2">
                   <h:outputText id="text2" styleClass="outputText" value="Footer"></h:outputText>
              </hx:outputLinkEx>
         </hx:scriptCollector></BODY>
    </f:view>
    </HTML>
    <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@taglib uri="/WEB-INF/mytaglib.tld" prefix="first"%>
    <f:subview id="server_req">
    <f:verbatim>
    <first:hello/>
    </f:verbatim>
    </f:subview>

    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 for Marquee in JSF

    Hi,
    I am trying to develop a custom tag for Marquee in JSF, my usecase is to display a value from managed bean(Dynamically). please find the code below and guide me where i have made mistake
    regards
    Sandeep
    Component class:
    package customtags;
    import javax.el.ValueExpression;
    import javax.faces.component.UIComponentBase;
    import javax.faces.context.FacesContext;
    public class Marquee extends UIComponentBase {
         public static final String COMPONENT_TYPE = "marqueecomp";
         public static final String RENDERER_TYPE = "marqueeRenderer";
         private Object[] _state = null;
         private String value;
         public String getValue() {
              if (null != this.value) {
                   return this.value;
              ValueExpression _ve = getValueExpression("value");
              return (_ve != null) ? (String) _ve.getValue(getFacesContext()
                        .getELContext()) : null;
         public void setValue(String marquee) {
              this.value = marquee;
         public String getFamily() {
              // TODO Auto-generated method stub
              return COMPONENT_TYPE;
    //     public void encodeBegin(FacesContext context) throws IOException {
    //          ResponseWriter writer = context.getResponseWriter();
    //          writer.startElement("marquee", this);
    //          writer.write(getValue());
    //          writer.endElement("marquee");
         public void restoreState(FacesContext context, Object state) {
              this._state = (Object[]) _state;
              super.restoreState(_context, this._state[0]);
              value = (String) this._state[1];
         public Object saveState(FacesContext _context) {
              if (_state == null) {
                   _state = new Object[2];
              state[0] = super.saveState(context);
              _state[1] = value;
              return _state;
    Tag Class:
    package customtags;
    import javax.el.ValueExpression;
    import javax.faces.component.UIComponent;
    import javax.faces.webapp.UIComponentELTag;
    public class MarqueeTag extends UIComponentELTag {
         protected ValueExpression marquee;
         public String getComponentType() {
              // TODO Auto-generated method stub
              return Marquee.COMPONENT_TYPE;
         public String getRendererType() {
              // TODO Auto-generated method stub
              return Marquee.RENDERER_TYPE;
         * protected void setProperties(UIComponent component) {
         * super.setProperties(component); Marquee marqComp = (Marquee) component;
         * if (marquee != null) { marqComp.setValue(marquee); } }
         protected void setProperties(UIComponent component) {
              super.setProperties(component);
              Marquee marqComp = null;
              try {
                   marqComp = (Marquee) component;
              } catch (ClassCastException cce) {
                   throw new IllegalStateException(
                             "Component "
                                       + component.toString()
                                       + " not expected type. Expected: com.foo.Foo. Perhaps you're missing a tag?");
              if (marquee != null) {
                   //marqComp.setValueExpression("value", marquee);
                   marqComp.setValue("fsdfsdfsdfsdfsd");
         * @return the marquee
         public ValueExpression getMarquee() {
              return marquee;
         * @param marquee
         * the marquee to set
         public void setMarquee(ValueExpression marquee) {
              this.marquee = marquee;
    *.tld file*
    <?xml version="1.0" encoding="UTF-8"?>
    <taglib xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
         version="2.1">
         <tlib-version>1.0</tlib-version>
         <short-name>marqueecomp</short-name>
         <uri>http://tags.org/marquee</uri>
         <tag>
              <name>marqueeTag</name>
    <tag-class>customtags.MarqueeTag</tag-class>
    <body-content>empty</body-content>
    <attribute>
    <description><![CDATA[Your description here]]></description>
    <name>id</name>
    <required>false</required>
    <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
    <description><![CDATA[Your description here]]></description>
    <name>value</name>
    </attribute>
         </tag>
    </taglib>
    Renderer class:
    package customtags;
    import java.io.IOException;
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.context.ResponseWriter;
    import javax.faces.render.Renderer;
    public class MarqueeRenderer extends Renderer {
         public void encodeBegin(final FacesContext facesContext,
    final UIComponent component) throws IOException {
    super.encodeBegin(facesContext, component);
    final ResponseWriter writer = facesContext.getResponseWriter();
    writer.startElement("DIV", component);
    /*String styleClass =
    (String)attributes.get(Shuffler.STYLECLASS_ATTRIBUTE_KEY);
    writer.writeAttribute("class", styleClass, null);*/
    public void encodeEnd(final FacesContext facesContext,
    final UIComponent component) throws IOException {
    final ResponseWriter writer = facesContext.getResponseWriter();
    writer.endElement("DIV");
    in Faces-Config:
    <component>
              <display-name>marqueecomp</display-name>
              <component-type>marqueecomp</component-type>
              <component-class>customtags.Marquee</component-class>
              <component-extension>
    <renderer-type>marqueeRenderer</renderer-type>
    </component-extension>
         </component>
         <render-kit>
    <renderer>
    <component-family>marqueecomp</component-family>
    <renderer-type>marqueeRenderer</renderer-type>
    <renderer-class>customtags.MarqueeRenderer</renderer-class>
    </renderer>
    </render-kit>
    In class path --->marquee.taglib.xml
    <?xml version="1.0"?>
    <!DOCTYPE facelet-taglib PUBLIC
    "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
    "http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
    <facelet-taglib>
    <namespace>http://tags.org/marquee</namespace>
    <tag>
    <tag-name>marqueeTag</tag-name>
    <component>
    <component-type>marqueecomp</component-type>
    <renderer-type>marqueeRenderer</renderer-type>
    </component>
    </tag>
    </facelet-taglib>
    *.xhtml file*
    <html xmlns="http://www.w3.org/1999/xhtml"
         xmlns:ui="http://java.sun.com/jsf/facelets"
         xmlns:h="http://java.sun.com/jsf/html"
         xmlns:f="http://java.sun.com/jsf/core" xml:lang="en" lang="en"
         xmlns:a4j="http://richfaces.org/a4j"
         xmlns:rich="http://richfaces.org/rich" xmlns:mycomp="http://tags.org/marquee">
    <head>
    <title>DEBTDOC Home Page</title>
    <meta http-equiv="keywords" content="enter,your,keywords,here" />
    <meta http-equiv="description"
         content="A short description of this page." />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" type="text/css" href="../css/common.css"></link>
    <script language="javascript" src="../script/common.js"></script>
    </head>
    <body>
    <f:view>
    <mycomp:marqueeTag value="hello World"></mycomp:marqueeTag>

    There exist the JSTL SQL taglib, but I don't recommend this. It should only be used for quick development and testing. For database connectivity, rather create a data layer with DAO classes which you on its turn just plug in your business layer (with servlets).

  • Problem using jsp:include from inside a custom tag

    Hi, All !
              I have a problem using <jsp:include> from inside a custom tag. Exception is:
              "java.lang.ClassCastException: weblogic.servlet.jsp.BodyContentImpl"
              Apparently, weblogic tries to cast BodyContentImpl to JspWriterImpl and
              could not do this. Is it a bug, since in the 1.1 spec is said: "The
              BodyContent is a subclass of JspWriter that can be used to process body
              evaluations so they can retrieved later on."
              My code is:
              <wfmklist:items>
              <jsp:include page="item.jsp" flush="true"/>
              </wfmklist:items>
              

    This is an area of contention with WL. It is not so tolerant with regards to
              the spec. I spent several days recently trying to convince it to accept the
              specification in regards to bodies and includes and it appears to have
              successfully rebuffed my efforts.
              Frankly, this is very disappointing. It appears that some shortcuts were
              taken on the way to JSP 1.1 support, and the result is a very hard-coded,
              inflexible implementation. As I have not seen the implementation myself, I
              hate to assume this, however one could posit that the term "interface" was a
              foreign concept during the implementation, other than as some annoying
              intermediary reference requiring an immediate cast to a specific Weblogic
              class, which in turn is apparently required to be final or have many final
              methods, as if being optimized for a JDK 1.02 JIT.
              I am sorry that I don't have any positive suggestions other than to use a
              URL object to come back in an execute the necessary "include" directly. You
              lose all context (other than session) and that can cause its own problems.
              However, you can generally get the URL approach to work, and you will
              hopefully avoid further frustration.
              Peace,
              Cameron Purdy
              Tangosol, Inc.
              http://www.tangosol.com
              Tangosol: How Weblogic applications are customized
              "Denis" <[email protected]> wrote in message
              news:[email protected]...
              > Hi, All !
              > I have a problem using <jsp:include> from inside a custom tag. Exception
              is:
              > "java.lang.ClassCastException: weblogic.servlet.jsp.BodyContentImpl"
              >
              > Apparently, weblogic tries to cast BodyContentImpl to JspWriterImpl and
              > could not do this. Is it a bug, since in the 1.1 spec is said: "The
              > BodyContent is a subclass of JspWriter that can be used to process body
              > evaluations so they can retrieved later on."
              >
              > My code is:
              > ...
              > <wfmklist:items>
              > <jsp:include page="item.jsp" flush="true"/>
              > </wfmklist:items>
              > ...
              

  • Adding custom tags and extend ParserDelegator and DTD support problem!!

    Hi all, I searched all forums and google for information about this problem but I did not find any clear solution or example.
    The probem stared when HTMLEditorKit's insertHTML method did not worked for custom tags.
    I extended javax.swing.text.html.parser.ParserDelegator class
    and override it's setDefaultDTD() method, which loads the default dtd (html32 definition). After the dtd field is created it I call this method:
              javax.swing.text.html.parser.Element element = _dtd.defineElement(
                  "template", javax.swing.text.html.parser.Element.SYSTEM, false, false,
                  null, null, null,
                  new AttributeList("value"));where _dtd is instance of DTD class in the same package, and "template" is the name of my custom tag.
    (if i define the element's type as CONTENT instead of SYSTEM the parser removes it)
    So after this,i see that my new tag is in DTD.elements vector and DTD.elementHash hastable, so its defined in DTD structures.
    The problem is that I have to redefine most element's ContentModel field "content" so that the parser will parse correctly the html source.
    Here is the tracing of DTD.elements vector default contents + template tag.Sorry for the long text but i just want to be clear
    Index i 0 element name #pcdata type 19 content null
    Index i 1 element name html type 18 content (head , body , plaintext?)
    Index i 2 element name meta type 17 content null
    Index i 3 element name base type 17 content null
    Index i 4 element name isindex type 17 content null
    Index i 5 element name head type 18 content (title? & isindex? & base? & nextid?)
    Index i 6 element name body type 18 content (h1 | h2 | h3 | h4 | h5 | h6 | p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | address | frameset | noframes | nohotjava | animate)*
    Index i 7 element name applet type 18 content ((p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)* | h1 | h2 | h3 | h4 | h5 | h6 | input | select | textarea | tr | td)*
    Index i 8 element name param type 17 content null
    Index i 9 element name p type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)*
    Index i 10 element name title type 18 content (#pcdata*)*
    Index i 11 element name style type 18 content (#pcdata*)*
    Index i 12 element name link type 17 content null
    Index i 13 element name plaintext type 1 content null
    Index i 14 element name nextid type 17 content null
    Index i 15 element name script type 18 content (h1 | h2 | h3 | h4 | h5 | h6 | p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | address | frameset | noframes | nohotjava | animate)*
    Index i 16 element name h1 type 18 content (img | br | hr | center | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)*
    Index i 17 element name h2 type 18 content (img | br | hr | center | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)*
    Index i 18 element name h3 type 18 content (img | br | hr | center | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)*
    Index i 19 element name h4 type 18 content (img | br | hr | center | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)*
    Index i 20 element name h5 type 18 content (img | br | hr | center | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)*
    Index i 21 element name h6 type 18 content (img | br | hr | center | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)*
    Index i 22 element name ul type 18 content (p | br | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | ol | ul | li)*
    Index i 23 element name ol type 18 content (p | br | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | ol | ul | li)*
    Index i 24 element name dir type 18 content (ul | ol | dir | menu | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | li)*
    Index i 25 element name menu type 18 content (ul | ol | dir | menu | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | li)*
    Index i 26 element name pre type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)*
    Index i 27 element name xmp type 1 content null
    Index i 28 element name listing type 1 content null
    Index i 29 element name dl type 18 content (p | dl | dt | dd)*
    Index i 30 element name div type 18 content (h1 | h2 | h3 | h4 | h5 | h6 | p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | address | frameset | noframes | nohotjava | animate)*
    Index i 31 element name center type 18 content (h1 | h2 | h3 | h4 | h5 | h6 | p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | address | frameset | noframes | nohotjava | animate)*
    Index i 32 element name blockquote type 18 content (h1 | h2 | h3 | h4 | h5 | h6 | p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | address | frameset | noframes | nohotjava | animate)*
    Index i 33 element name form type 18 content (h1 | h2 | h3 | h4 | h5 | h6 | p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | address | frameset | noframes | nohotjava | animate)*
    Index i 34 element name hr type 17 content null
    Index i 35 element name table type 18 content (tr | caption)*
    Index i 36 element name object type 18 content (param | (h1 | h2 | h3 | h4 | h5 | h6 | (p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)* | address)* | input | select | textarea)*
    Index i 37 element name tt type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 38 element name i type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 39 element name b type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 40 element name u type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 41 element name strike type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 42 element name s type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 43 element name big type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 44 element name small type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 45 element name sub type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 46 element name sup type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 47 element name em type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 48 element name strong type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 49 element name dfn type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 50 element name code type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 51 element name samp type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 52 element name kbd type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 53 element name var type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 54 element name cite type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 55 element name a type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | h1 | h2 | h3 | h4 | h5 | h6 | pre)*
    Index i 56 element name img type 17 content null
    Index i 57 element name font type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 58 element name basefont type 17 content null
    Index i 59 element name br type 17 content null
    Index i 60 element name map type 18 content (base | area)*
    Index i 61 element name nobr type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)+
    Index i 62 element name wbr type 17 content null
    Index i 63 element name blink type 19 content null
    Index i 64 element name input type 17 content null
    Index i 65 element name select type 18 content (option+)
    Index i 66 element name textarea type 18 content (#pcdata*)*
    Index i 67 element name address type 18 content ((#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea) | p)*
    Index i 68 element name frameset type 18 content (frameset | frame | noframes)*
    Index i 69 element name noframes type 1 content null
    Index i 70 element name nohotjava type 1 content null
    Index i 71 element name animate type 1 content null
    Index i 72 element name tr type 18 content (td | th | script | map)*
    Index i 73 element name td type 18 content (h1 | h2 | h3 | h4 | h5 | h6 | p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | address | frameset | noframes | nohotjava | animate)*
    Index i 74 element name area type 17 content null
    Index i 75 element name option type 18 content (#pcdata*)*
    Index i 76 element name dt type 18 content (h1 | h2 | h3 | h4 | h5 | h6 | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)*
    Index i 77 element name dd type 18 content (p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)*
    Index i 78 element name li type 18 content ((p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)* | h1 | h2 | h3 | h4 | h5 | h6)*
    Index i 79 element name caption type 18 content (h1 | h2 | h3 | h4 | h5 | h6 | p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | address | frameset | noframes | nohotjava | animate)*
    Index i 80 element name frame type 17 content null
    Index i 81 element name th type 18 content (h1 | h2 | h3 | h4 | h5 | h6 | p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | address | frameset | noframes | nohotjava | animate)*
    Index i 82 element name template type 17 content null
    Can anyone plase give me advice how i can add my custom tag in this ContentModel structures for example as a content of "p" element
    I must do this for most structure elements.
    Or tell me any other way i can achieve the solution of my problem.
    A lot of topics here are still opened for solution for similar problems.
    and hope that there is any solution for my problem 'cause its urgent.
    Thanks in advance.
    Nenko Ivanov

    Hi all, I searched all forums and google for information about this problem but I did not find any clear solution or example.
    The probem stared when HTMLEditorKit's insertHTML method did not worked for custom tags.
    I extended javax.swing.text.html.parser.ParserDelegator class
    and override it's setDefaultDTD() method, which loads the default dtd (html32 definition). After the dtd field is created it I call this method:
              javax.swing.text.html.parser.Element element = _dtd.defineElement(
                  "template", javax.swing.text.html.parser.Element.SYSTEM, false, false,
                  null, null, null,
                  new AttributeList("value"));where _dtd is instance of DTD class in the same package, and "template" is the name of my custom tag.
    (if i define the element's type as CONTENT instead of SYSTEM the parser removes it)
    So after this,i see that my new tag is in DTD.elements vector and DTD.elementHash hastable, so its defined in DTD structures.
    The problem is that I have to redefine most element's ContentModel field "content" so that the parser will parse correctly the html source.
    Here is the tracing of DTD.elements vector default contents + template tag.Sorry for the long text but i just want to be clear
    Index i 0 element name #pcdata type 19 content null
    Index i 1 element name html type 18 content (head , body , plaintext?)
    Index i 2 element name meta type 17 content null
    Index i 3 element name base type 17 content null
    Index i 4 element name isindex type 17 content null
    Index i 5 element name head type 18 content (title? & isindex? & base? & nextid?)
    Index i 6 element name body type 18 content (h1 | h2 | h3 | h4 | h5 | h6 | p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | address | frameset | noframes | nohotjava | animate)*
    Index i 7 element name applet type 18 content ((p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)* | h1 | h2 | h3 | h4 | h5 | h6 | input | select | textarea | tr | td)*
    Index i 8 element name param type 17 content null
    Index i 9 element name p type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)*
    Index i 10 element name title type 18 content (#pcdata*)*
    Index i 11 element name style type 18 content (#pcdata*)*
    Index i 12 element name link type 17 content null
    Index i 13 element name plaintext type 1 content null
    Index i 14 element name nextid type 17 content null
    Index i 15 element name script type 18 content (h1 | h2 | h3 | h4 | h5 | h6 | p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | address | frameset | noframes | nohotjava | animate)*
    Index i 16 element name h1 type 18 content (img | br | hr | center | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)*
    Index i 17 element name h2 type 18 content (img | br | hr | center | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)*
    Index i 18 element name h3 type 18 content (img | br | hr | center | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)*
    Index i 19 element name h4 type 18 content (img | br | hr | center | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)*
    Index i 20 element name h5 type 18 content (img | br | hr | center | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)*
    Index i 21 element name h6 type 18 content (img | br | hr | center | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)*
    Index i 22 element name ul type 18 content (p | br | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | ol | ul | li)*
    Index i 23 element name ol type 18 content (p | br | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | ol | ul | li)*
    Index i 24 element name dir type 18 content (ul | ol | dir | menu | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | li)*
    Index i 25 element name menu type 18 content (ul | ol | dir | menu | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | li)*
    Index i 26 element name pre type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)*
    Index i 27 element name xmp type 1 content null
    Index i 28 element name listing type 1 content null
    Index i 29 element name dl type 18 content (p | dl | dt | dd)*
    Index i 30 element name div type 18 content (h1 | h2 | h3 | h4 | h5 | h6 | p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | address | frameset | noframes | nohotjava | animate)*
    Index i 31 element name center type 18 content (h1 | h2 | h3 | h4 | h5 | h6 | p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | address | frameset | noframes | nohotjava | animate)*
    Index i 32 element name blockquote type 18 content (h1 | h2 | h3 | h4 | h5 | h6 | p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | address | frameset | noframes | nohotjava | animate)*
    Index i 33 element name form type 18 content (h1 | h2 | h3 | h4 | h5 | h6 | p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | address | frameset | noframes | nohotjava | animate)*
    Index i 34 element name hr type 17 content null
    Index i 35 element name table type 18 content (tr | caption)*
    Index i 36 element name object type 18 content (param | (h1 | h2 | h3 | h4 | h5 | h6 | (p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)* | address)* | input | select | textarea)*
    Index i 37 element name tt type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 38 element name i type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 39 element name b type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 40 element name u type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 41 element name strike type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 42 element name s type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 43 element name big type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 44 element name small type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 45 element name sub type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 46 element name sup type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 47 element name em type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 48 element name strong type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 49 element name dfn type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 50 element name code type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 51 element name samp type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 52 element name kbd type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 53 element name var type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 54 element name cite type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 55 element name a type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | h1 | h2 | h3 | h4 | h5 | h6 | pre)*
    Index i 56 element name img type 17 content null
    Index i 57 element name font type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | center | p | dl | ul | ol)*
    Index i 58 element name basefont type 17 content null
    Index i 59 element name br type 17 content null
    Index i 60 element name map type 18 content (base | area)*
    Index i 61 element name nobr type 18 content (#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)+
    Index i 62 element name wbr type 17 content null
    Index i 63 element name blink type 19 content null
    Index i 64 element name input type 17 content null
    Index i 65 element name select type 18 content (option+)
    Index i 66 element name textarea type 18 content (#pcdata*)*
    Index i 67 element name address type 18 content ((#pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea) | p)*
    Index i 68 element name frameset type 18 content (frameset | frame | noframes)*
    Index i 69 element name noframes type 1 content null
    Index i 70 element name nohotjava type 1 content null
    Index i 71 element name animate type 1 content null
    Index i 72 element name tr type 18 content (td | th | script | map)*
    Index i 73 element name td type 18 content (h1 | h2 | h3 | h4 | h5 | h6 | p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | address | frameset | noframes | nohotjava | animate)*
    Index i 74 element name area type 17 content null
    Index i 75 element name option type 18 content (#pcdata*)*
    Index i 76 element name dt type 18 content (h1 | h2 | h3 | h4 | h5 | h6 | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)*
    Index i 77 element name dd type 18 content (p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)*
    Index i 78 element name li type 18 content ((p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea)* | h1 | h2 | h3 | h4 | h5 | h6)*
    Index i 79 element name caption type 18 content (h1 | h2 | h3 | h4 | h5 | h6 | p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | address | frameset | noframes | nohotjava | animate)*
    Index i 80 element name frame type 17 content null
    Index i 81 element name th type 18 content (h1 | h2 | h3 | h4 | h5 | h6 | p | ul | ol | dir | menu | pre | xmp | listing | plaintext | dl | div | center | blockquote | form | isindex | hr | table | object | #pcdata* | tt | i | b | u | strike | s | big | small | sub | sup | em | strong | dfn | code | samp | kbd | var | cite | a | img | applet | object | font | basefont | br | script | map | nobr | wbr | blink | input | select | textarea | address | frameset | noframes | nohotjava | animate)*
    Index i 82 element name template type 17 content null
    Can anyone plase give me advice how i can add my custom tag in this ContentModel structures for example as a content of "p" element
    I must do this for most structure elements.
    Or tell me any other way i can achieve the solution of my problem.
    A lot of topics here are still opened for solution for similar problems.
    and hope that there is any solution for my problem 'cause its urgent.
    Thanks in advance.
    Nenko Ivanov

  • Unwanted body evaluation of a custom tag

    Following custom tag should output:
    [Tag Test]
    a
    b
    c
    This is another test
    a
    b
    c
    This bad boy!
    a
    b
    c
    But, in reality, the output is as follows:
    [Tag Test]
    a
    b
    c
    This is another test
    c
    a
    b
    c
    This bad boy!
    c
    a
    b
    c
    As you can see, everytime the tag is executed, unwanted body evaluation has occured before the assignment to a page-scope variable. What coud be the cause of the problem?
    /* tag handler */
    package mytag;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    import java.io.*;
    import javax.servlet.http.*;
    import java.util.*;
    public class foreach extends BodyTagSupport{
      private Iterator iterator;
      private String group;
      public void setGroup(String group){
        this.group = group;
      public  String getGroup(){
        return group;
      public int doStartTag() throws JspException{
        try{
          String[] intarray = new String[] {"a","b","c"};
          ArrayList ar = new ArrayList(Arrays.asList(intarray));
          iterator = ar.iterator();
          if (iterator.hasNext()){
            return EVAL_BODY_BUFFERED;
          else{
           return SKIP_BODY;
        catch (Exception e){
          System.err.println(e);
        return SKIP_BODY;
      public int doAfterBody() throws JspException{
        try{
          if (iterator == null){
            return SKIP_BODY;
          if (iterator.hasNext()) {
            String o = (String)iterator.next();
            pageContext.setAttribute("a1", o);   
            return EVAL_BODY_AGAIN;
          else{
            return SKIP_BODY;
        catch (Exception e){
          System.err.println(e);
        return SKIP_BODY;
      public int doEndTag() throws JspException {
        try {
          pageContext.getOut().print(bodyContent.getString());
        catch(Exception ioe) {
          System.out.println(ioe);
        return EVAL_PAGE;
    --test.jsp---
    <%@ page contentType="text/html" %>
    <%@ taglib prefix="jrun" uri="/WEB-INF/mytag.tld" %>
    <html><body bgcolor="lightgreen">
    <hr>
    [Tag Test]<br>
    <jrun:foreach group="itemsql">
    ${a1}<br>
    </jrun:foreach>
    <hr>
    This is another test<br>
    <jrun:foreach group="itemsql">
    ${a1}<br>
    </jrun:foreach>
    <hr>
    This bad boy!<br>
    <jrun:foreach group="itemsql">
    ${a1}<br>
    </jrun:foreach>
    <hr></body></html>
    --TLD-----------
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!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></short-name>
      <description>
      </description>
      <tag>
        <name>foreach</name>
        <tag-class>mytag.foreach</tag-class>
        <body-content>JSP</body-content>
        <description>
        </description>
        <attribute>
          <name>group</name>
          <required>true</required>
          <rtexprvalue>true</rtexprvalue>
        </attribute>
      </tag>
    </taglib>

    Never mind. I've found the cause of my problem. I shoud hava started the iterator in the doStartTag() metod instead of in the doAfterBody().

Maybe you are looking for