Hi, This is a known issue is Tomcat 6.0.14, it was reported using http://issues.apache.org/bugzilla/show_bug.cgi?id=42693 and it is fixed in the trunk.
Regards, lg On Jan 6, 2008 1:50 PM, Jair da Silva Ferreira Jr <[EMAIL PROTECTED]> wrote: > Hi, > I am experiencing a problem with recursivity in tag files in tomcat > 6.0.14. I developed a simple tag file to show you the problem. > Here is my tag file: > > <%@ tag body-content="empty" %> > <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> > <%@ taglib prefix="t" tagdir="/WEB-INF/tags" %> > > <%@ attribute name="number" required="true" type="java.lang.Integer" %> > <c:choose> > <c:when test="${number==0 || number==1}">1</c:when> > <c:otherwise>${number}*<t:factorial number="${number-1}"/></c:otherwise> > </c:choose> > > The tag file is pretty simple. When called from a jsp file, the tag > outputs how the factorial of any given number is calculated, but it > doen't actually calculate the factorial result. For example: if the > "number" paramenter is 5, the tag will output 5*4*3*2*1. > Here is the portion of the jsp file that calls the tag: > <c:if test="${! empty param.number}"> > Result: <t:factorial number="${param.number}"/> > </c:if> > > The problem is that nothing is displayed when the tag is called form > a jsp file. It happens as if the tag is not being called at all or as if > it is an empty tag file. > After some work I found out the problem. Jasper is not correctly > converting my recursive tag file to java code. The resulting java file > found in tomcat's work directory has an empty doTag method. Here is the > doTag method: > public void doTag() throws JspException, java.io.IOException { > } > > I've checked all tomcat logs and couldn't find any jasper error message. > I've run the same web application in two different systems and the > problem only happens in system 2. Here is the configuration: > > System 1 (development machine) (problem does not happen): > - OS: Windows XP sp2 > - Hardware: AMD Athlon XP 2400+ (2.03 GHz) (1,5 GB RAM) > - Java (as stated by "java -version" command): > java version "1.6.0_03" > Java(TM) SE Runtime Environment (build 1.6.0_03-b05) > Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, > sharing) > - Tomcat version: 6.0.14 (.zip download package) > System 2 (production machine) (problem happens): > - OS: Ubuntu linux 7.10 (codename gutsy) > - Hardware: HP Tower Computer ProLiant ML350 G5, Intel(R) > Xeon(R) CPU 5120 @ 1.86GHz, 4 GB RAM > - Java (as stated by "java -version" command): > java version "1.6.0_03" > Java(TM) SE Runtime Environment (build 1.6.0_03-b05) > Java HotSpot(TM) Server VM (build 1.6.0_03-b05, mixed mode) > - Tomcat version: 6.0.14 (.tar.gz download package) > > I am sending you my factorial example web application. The file is > recursive-tag.war. The application only has 2 files: index.jsp and > factorial.tag. > I am also sending you 2 jasper generated .java files extracted from > the tomcat work directory. "system1_factorial_tag.java" is generated in > the system 1 configuration and "system2_factorial_tag.java" is generated > in the system 2 configuration. Please, notice that the "doTag" method is > empty in "system2_factorial_tag.java". > Please, can anyone help me with this problem? Am I doing something > wrong? > Thank you very much. > > Sincerely, > Jair Jr > > package org.apache.jsp.tag.web; > > import javax.servlet.*; > import javax.servlet.http.*; > import javax.servlet.jsp.*; > > public final class factorial_tag > extends javax.servlet.jsp.tagext.SimpleTagSupport > implements org.apache.jasper.runtime.JspSourceDependent { > > > private static final JspFactory _jspxFactory = > JspFactory.getDefaultFactory(); > > private static java.util.List _jspx_dependants; > > private JspContext jspContext; > private java.io.Writer _jspx_sout; > private org.apache.jasper.runtime.TagHandlerPool > _005fjspx_005ftagPool_005fc_005fchoose; > private org.apache.jasper.runtime.TagHandlerPool > _005fjspx_005ftagPool_005fc_005fwhen_005ftest; > private org.apache.jasper.runtime.TagHandlerPool > _005fjspx_005ftagPool_005fc_005fotherwise; > > private javax.el.ExpressionFactory _el_expressionfactory; > private org.apache.AnnotationProcessor _jsp_annotationprocessor; > > public void setJspContext(JspContext ctx) { > super.setJspContext(ctx); > java.util.ArrayList _jspx_nested = null; > java.util.ArrayList _jspx_at_begin = null; > java.util.ArrayList _jspx_at_end = null; > this.jspContext = new org.apache.jasper.runtime.JspContextWrapper(ctx, > _jspx_nested, _jspx_at_begin, _jspx_at_end, null); > } > > public JspContext getJspContext() { > return this.jspContext; > } > private java.lang.Integer number; > > public java.lang.Integer getNumber() { > return this.number; > } > > public void setNumber(java.lang.Integer number) { > this.number = number; > jspContext.setAttribute("number", number); > } > > public Object getDependants() { > return _jspx_dependants; > } > > private void _jspInit(ServletConfig config) { > _005fjspx_005ftagPool_005fc_005fchoose = > org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(config); > _005fjspx_005ftagPool_005fc_005fwhen_005ftest = > org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(config); > _005fjspx_005ftagPool_005fc_005fotherwise = > org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(config); > _el_expressionfactory = > _jspxFactory.getJspApplicationContext(config.getServletContext()).getExpressionFactory(); > _jsp_annotationprocessor = (org.apache.AnnotationProcessor) > config.getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName()); > } > > public void _jspDestroy() { > _005fjspx_005ftagPool_005fc_005fchoose.release(); > _005fjspx_005ftagPool_005fc_005fwhen_005ftest.release(); > _005fjspx_005ftagPool_005fc_005fotherwise.release(); > } > > public void doTag() throws JspException, java.io.IOException { > PageContext _jspx_page_context = (PageContext)jspContext; > HttpServletRequest request = (HttpServletRequest) > _jspx_page_context.getRequest(); > HttpServletResponse response = (HttpServletResponse) > _jspx_page_context.getResponse(); > HttpSession session = _jspx_page_context.getSession(); > ServletContext application = _jspx_page_context.getServletContext(); > ServletConfig config = _jspx_page_context.getServletConfig(); > JspWriter out = jspContext.getOut(); > _jspInit(config); > jspContext.getELContext().putContext(JspContext.class,jspContext); > if( getNumber() != null ) > _jspx_page_context.setAttribute("number", getNumber()); > > try { > out.write("\r\n"); > out.write("\r\n"); > out.write("\r\n"); > out.write("\r\n"); > out.write("\r\n"); > if (_jspx_meth_c_005fchoose_005f0(_jspx_page_context)) > return; > } catch( Throwable t ) { > if( t instanceof SkipPageException ) > throw (SkipPageException) t; > if( t instanceof java.io.IOException ) > throw (java.io.IOException) t; > if( t instanceof IllegalStateException ) > throw (IllegalStateException) t; > if( t instanceof JspException ) > throw (JspException) t; > throw new JspException(t); > } finally { > > jspContext.getELContext().putContext(JspContext.class,super.getJspContext()); > ((org.apache.jasper.runtime.JspContextWrapper) > jspContext).syncEndTagFile(); > _jspDestroy(); > } > } > > private boolean _jspx_meth_c_005fchoose_005f0(PageContext > _jspx_page_context) > throws Throwable { > JspWriter out = _jspx_page_context.getOut(); > // c:choose > org.apache.taglibs.standard.tag.common.core.ChooseTag > _jspx_th_c_005fchoose_005f0 = > (org.apache.taglibs.standard.tag.common.core.ChooseTag) > _005fjspx_005ftagPool_005fc_005fchoose.get(org.apache.taglibs.standard.tag.common.core.ChooseTag.class); > _jspx_th_c_005fchoose_005f0.setPageContext(_jspx_page_context); > _jspx_th_c_005fchoose_005f0.setParent(new > javax.servlet.jsp.tagext.TagAdapter((javax.servlet.jsp.tagext.SimpleTag) this > )); int _jspx_eval_c_005fchoose_005f0 = > _jspx_th_c_005fchoose_005f0.doStartTag(); > if (_jspx_eval_c_005fchoose_005f0 != > javax.servlet.jsp.tagext.Tag.SKIP_BODY) { > do { > out.write('\r'); > out.write('\n'); > out.write(' '); > if (_jspx_meth_c_005fwhen_005f0(_jspx_th_c_005fchoose_005f0, > _jspx_page_context)) > return true; > out.write('\r'); > out.write('\n'); > out.write(' '); > if (_jspx_meth_c_005fotherwise_005f0(_jspx_th_c_005fchoose_005f0, > _jspx_page_context)) > return true; > out.write('\r'); > out.write('\n'); > int evalDoAfterBody = _jspx_th_c_005fchoose_005f0.doAfterBody(); > if (evalDoAfterBody != > javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) > break; > } while (true); > } > if (_jspx_th_c_005fchoose_005f0.doEndTag() == > javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { > > _005fjspx_005ftagPool_005fc_005fchoose.reuse(_jspx_th_c_005fchoose_005f0); > throw new SkipPageException(); > } > _005fjspx_005ftagPool_005fc_005fchoose.reuse(_jspx_th_c_005fchoose_005f0); > return false; > } > > private boolean _jspx_meth_c_005fwhen_005f0(javax.servlet.jsp.tagext.JspTag > _jspx_th_c_005fchoose_005f0, PageContext _jspx_page_context) > throws Throwable { > JspWriter out = _jspx_page_context.getOut(); > // c:when > org.apache.taglibs.standard.tag.rt.core.WhenTag _jspx_th_c_005fwhen_005f0 > = (org.apache.taglibs.standard.tag.rt.core.WhenTag) > _005fjspx_005ftagPool_005fc_005fwhen_005ftest.get(org.apache.taglibs.standard.tag.rt.core.WhenTag.class); > _jspx_th_c_005fwhen_005f0.setPageContext(_jspx_page_context); > _jspx_th_c_005fwhen_005f0.setParent((javax.servlet.jsp.tagext.Tag) > _jspx_th_c_005fchoose_005f0); > // /WEB-INF/tags/factorial.tag(7,1) name = test type = boolean reqTime = > true required = true fragment = false deferredValue = false expectedTypeName > = null deferredMethod = false methodSignature = null > _jspx_th_c_005fwhen_005f0.setTest(((java.lang.Boolean) > org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${number==0 || > number==1}", java.lang.Boolean.class, (PageContext)this.getJspContext(), > null, false)).booleanValue()); > int _jspx_eval_c_005fwhen_005f0 = _jspx_th_c_005fwhen_005f0.doStartTag(); > if (_jspx_eval_c_005fwhen_005f0 != > javax.servlet.jsp.tagext.Tag.SKIP_BODY) { > do { > out.write('1'); > int evalDoAfterBody = _jspx_th_c_005fwhen_005f0.doAfterBody(); > if (evalDoAfterBody != > javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) > break; > } while (true); > } > if (_jspx_th_c_005fwhen_005f0.doEndTag() == > javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { > > _005fjspx_005ftagPool_005fc_005fwhen_005ftest.reuse(_jspx_th_c_005fwhen_005f0); > throw new SkipPageException(); > } > > _005fjspx_005ftagPool_005fc_005fwhen_005ftest.reuse(_jspx_th_c_005fwhen_005f0); > return false; > } > > private boolean > _jspx_meth_c_005fotherwise_005f0(javax.servlet.jsp.tagext.JspTag > _jspx_th_c_005fchoose_005f0, PageContext _jspx_page_context) > throws Throwable { > JspWriter out = _jspx_page_context.getOut(); > // c:otherwise > org.apache.taglibs.standard.tag.common.core.OtherwiseTag > _jspx_th_c_005fotherwise_005f0 = > (org.apache.taglibs.standard.tag.common.core.OtherwiseTag) > _005fjspx_005ftagPool_005fc_005fotherwise.get(org.apache.taglibs.standard.tag.common.core.OtherwiseTag.class); > _jspx_th_c_005fotherwise_005f0.setPageContext(_jspx_page_context); > _jspx_th_c_005fotherwise_005f0.setParent((javax.servlet.jsp.tagext.Tag) > _jspx_th_c_005fchoose_005f0); > int _jspx_eval_c_005fotherwise_005f0 = > _jspx_th_c_005fotherwise_005f0.doStartTag(); > if (_jspx_eval_c_005fotherwise_005f0 != > javax.servlet.jsp.tagext.Tag.SKIP_BODY) { > do { > out.write((java.lang.String) > org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${number}", > java.lang.String.class, (PageContext)this.getJspContext(), null, false)); > out.write('*'); > if (_jspx_meth_t_005ffactorial_005f0(_jspx_th_c_005fotherwise_005f0, > _jspx_page_context)) > return true; > int evalDoAfterBody = _jspx_th_c_005fotherwise_005f0.doAfterBody(); > if (evalDoAfterBody != > javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) > break; > } while (true); > } > if (_jspx_th_c_005fotherwise_005f0.doEndTag() == > javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { > > _005fjspx_005ftagPool_005fc_005fotherwise.reuse(_jspx_th_c_005fotherwise_005f0); > throw new SkipPageException(); > } > > _005fjspx_005ftagPool_005fc_005fotherwise.reuse(_jspx_th_c_005fotherwise_005f0); > return false; > } > > private boolean > _jspx_meth_t_005ffactorial_005f0(javax.servlet.jsp.tagext.JspTag > _jspx_th_c_005fotherwise_005f0, PageContext _jspx_page_context) > throws Throwable { > JspWriter out = _jspx_page_context.getOut(); > // t:factorial > org.apache.jsp.tag.web.factorial_tag _jspx_th_t_005ffactorial_005f0 = new > org.apache.jsp.tag.web.factorial_tag(); > > org.apache.jasper.runtime.AnnotationHelper.postConstruct(_jsp_annotationprocessor, > _jspx_th_t_005ffactorial_005f0); > _jspx_th_t_005ffactorial_005f0.setJspContext(_jspx_page_context); > _jspx_th_t_005ffactorial_005f0.setParent(_jspx_th_c_005fotherwise_005f0); > // /WEB-INF/tags/factorial.tag(8,24) name = number type = > java.lang.Integer reqTime = true required = true fragment = false > deferredValue = false expectedTypeName = java.lang.String deferredMethod = > false methodSignature = null > _jspx_th_t_005ffactorial_005f0.setNumber((java.lang.Integer) > org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${number-1}", > java.lang.Integer.class, (PageContext)this.getJspContext(), null, false)); > _jspx_th_t_005ffactorial_005f0.doTag(); > > org.apache.jasper.runtime.AnnotationHelper.preDestroy(_jsp_annotationprocessor, > _jspx_th_t_005ffactorial_005f0); > return false; > } > } > > package org.apache.jsp.tag.web; > > import javax.servlet.*; > import javax.servlet.http.*; > import javax.servlet.jsp.*; > > public final class factorial_tag > extends javax.servlet.jsp.tagext.SimpleTagSupport > implements org.apache.jasper.runtime.JspSourceDependent { > > > private static final JspFactory _jspxFactory = > JspFactory.getDefaultFactory(); > > private static java.util.List _jspx_dependants; > > private JspContext jspContext; > private java.io.Writer _jspx_sout; > private org.apache.jasper.runtime.TagHandlerPool > _005fjspx_005ftagPool_005fc_005fchoose; > private org.apache.jasper.runtime.TagHandlerPool > _005fjspx_005ftagPool_005fc_005fwhen_005ftest; > private org.apache.jasper.runtime.TagHandlerPool > _005fjspx_005ftagPool_005fc_005fotherwise; > > private javax.el.ExpressionFactory _el_expressionfactory; > private org.apache.AnnotationProcessor _jsp_annotationprocessor; > > public void setJspContext(JspContext ctx) { > super.setJspContext(ctx); > java.util.ArrayList _jspx_nested = null; > java.util.ArrayList _jspx_at_begin = null; > java.util.ArrayList _jspx_at_end = null; > this.jspContext = new org.apache.jasper.runtime.JspContextWrapper(ctx, > _jspx_nested, _jspx_at_begin, _jspx_at_end, null); > } > > public JspContext getJspContext() { > return this.jspContext; > } > private java.lang.Integer number; > > public java.lang.Integer getNumber() { > return this.number; > } > > public void setNumber(java.lang.Integer number) { > this.number = number; > jspContext.setAttribute("number", number); > } > > public Object getDependants() { > return _jspx_dependants; > } > > private void _jspInit(ServletConfig config) { > _005fjspx_005ftagPool_005fc_005fchoose = > org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(config); > _005fjspx_005ftagPool_005fc_005fwhen_005ftest = > org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(config); > _005fjspx_005ftagPool_005fc_005fotherwise = > org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(config); > _el_expressionfactory = > _jspxFactory.getJspApplicationContext(config.getServletContext()).getExpressionFactory(); > _jsp_annotationprocessor = (org.apache.AnnotationProcessor) > config.getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName()); > } > > public void _jspDestroy() { > _005fjspx_005ftagPool_005fc_005fchoose.release(); > _005fjspx_005ftagPool_005fc_005fwhen_005ftest.release(); > _005fjspx_005ftagPool_005fc_005fotherwise.release(); > } > > public void doTag() throws JspException, java.io.IOException { > } > } > > > --------------------------------------------------------------------- > To start a new topic, e-mail: [email protected] > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To start a new topic, e-mail: [email protected] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
