DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13194>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13194

refreshing JSP containing a body tag gives problem on alternate refresh

           Summary: refreshing JSP containing a body tag gives problem on
                    alternate refresh
           Product: Tomcat 4
           Version: 4.1.12
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Catalina
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


suspect that the release() is not executed after the taghandler instance's 
lifecycle has ended.

to produce bug, 
1. copy the tld file to webapp root. 
2. compile the tag handler to <webapp>/WEB-INF/classes. 
3. copy test.jsp to server and access it.
4. refresh the page(test.jsp), java.lang.ArrayIndexOutOfBoundsException will be 
encountered on alternate browser refresh.


tld file
------------------
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
 PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
 "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd";>
<taglib>
  <tlibversion>1.0</tlibversion>
  <jspversion>1.1</jspversion>
  <shortname>test</shortname>
  <info>
    A tag library for the pagination, product of Ecquaria Technologies Pte Ltd.
    http://www.ecquaria.com/.
  </info>

        <tag>
                <name>loop</name>
                <tagclass>test.ArrayTag</tagclass>
        </tag>

</taglib>



Taghandler
-----------------------
package test;
import java.io.*;
import java.util.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;

public class ArrayTag extends BodyTagSupport{
        private BodyContent bodyContent;
        private int index = -1;
        private final int[] data = new int[] {0, 1, 2};

////////////////// tag support interface methods //////////////////////////
        public void setBodyContent(BodyContent b) {
                this.bodyContent = b;
        }

  /**
   * Method called at start of Tag
   * @return either a EVAL_BODY_TAG or a SKIP_BODY
   */
        public int doStartTag() throws javax.servlet.jsp.JspException {
                return EVAL_BODY_TAG;
        }//doStartTag

        //only only be called at most once
        public void doInitBody() throws JspException {}

        //@return EVAL_BODY_TAG, SKIP_BODY
        public int doAfterBody() throws JspException{
                ++index;
                System.out.print("[ArrayTag] index: " + index );
                System.out.println(", current data: " + data[index]);
                return (index<data.length-1) ? EVAL_BODY_TAG : SKIP_BODY;
        }


        /**
         * Method called at end of Tag
         * @return either EVAL_PAGE or SKIP_PAGE
         */
        public int doEndTag() throws javax.servlet.jsp.JspException {
                System.out.println("in doEndTag.");
                return EVAL_PAGE;       //to continue evaluating the rest of 
the JSP.
        }//doEndTag


        /** Reset the state of the tag, to enable reuse of tag handler 
instances. */
        public void release() {
                this.bodyContent = null;
                this.index = -1;
                super.release();
        }//release

}//class ArrayTag



test.jsp
-----------------
<%@ taglib uri="/test.tld" prefix="test"%>
<%
  int iii = 0;
  System.out.println("\n\n-------------");
%>

<html>
<body>
hi there!
<test:loop>
        <%
                System.out.println("iii: " + (iii++));
        %>
</test:loop>

</body>
</html>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to