• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IterationTag-TagSupport

 
ashok khetan
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi!
given below is a tag-handler class:
________
package mytagdir;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
public class MyPage extends TagSupport {
int k=10;
public int doStartTag() throws JspException {
return EVAL_BODY_INCLUDE;
}
public int doAfterBody() throws JspException {
if(k<13) {
k++;
return EVAL_BODY_AGAIN;
}
return SKIP_BODY;
}
public int doEndTag() throws JspException {
return EVAL_PAGE;
}
}
________
the custom tags in MyJsp.jsp are (excluding the taglib directive)
<test:God>
<%="in tag" %>
</test:God>
I think the output should be "in tag" four times becos' TagSupport class implements the IterationTag interface and there should be no problem in evaluating the body again and again. But when accessed, the browser shows the following error(I am using Tomcat4.0)
java.lang.VerifyError: (class: org/apache/jsp/MyJsp$jsp, method: _jspService signature: (Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse)V) Incompatible object argument for function call
I couldn't get where is the problem?
ashok.
[This message has been edited by ashok khetan (edited November 02, 2001).]
 
satish kolli
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see any problem. I ran this stuff in Tomcat and it is working fine.
Thanks!
Satish Kolli, SCJP2
 
ruijin yang
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ashok,
The problem is in tag's body."in tag" is a String,
do not use tag expression.Try this,it will be Ok.
<test:God>
in tag
</test:God>
But if we extends BodyTagSupport,
<test:God>
<%="in tag"%>
</test:God>
This will be ok.
I do not know why.
ruijin yang


[This message has been edited by ruijin yang (edited November 04, 2001).]
 
ruijin yang
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Now I think I know why the above situations occured.
For TagSupport,only passed through tag's body,not processing
tag's body. e.g. in tag;
For BodyTagSupport,it can process tag's body,e.g. tag expression: <%="in tag"%>.
ruijin yang
 
Win Yu
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still not clear about this.
 
ruijin yang
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Win,
I already realized that my above explanation is not correct.
Sorry.
ruijin yang
Originally posted by Win Yu:
Still not clear about this.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic