Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compilation error for EVAL_BODY_AGAIN

 
Ritu varada
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying out a custom tag example. I am running tomcat5 andd have the jsp-api.jar in my classpath. I know that is okay because I have been able to execute Simple tags. Anyway, here is the custom tag

package foo;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;
import java.io.IOException;



public class CustomTagTest3 extends TagSupport {

int movieCounter;
String[] movies = {"Amelie","Sandy beaches","Veer zara","SomethingElse"};

public int doStartTag() throws JspException {
movieCounter = 0;

return EVAL_BODY_INCLUDE;
}

public int doAfterBody() throws JspException {

if (movieCounter < movies.length) {
pageContext.setAttribute("movie",movies[movieCounter]);
movieCounter++;
return EVAL_BODY_AGAIN;
}
else {
return SKIP_BODY;
}
}
public int doEndTag() throws JspException {

return EVAL_PAGE;
}
}

I am getting the below compilation error.

C:\HEADFI~1\CustomTagTest3>javac foo\CustomTagTest3.java
foo\CustomTagTest3.java:26: cannot resolve symbol
symbol : variable EVAL_BODY_AGAIN
location: class foo.CustomTagTest3
return EVAL_BODY_AGAIN;
^
1 error


I know that EVAL_BODY_AGAIN is a valid return value for doAfterBody(). What am I missing ?
 
Ritu varada
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I tried that and it still did not work. Anyway, TagSupport should do for doAfterBody() method. Does the class compile for you ? Thanks for your help!
 
Nischal Tanna
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ritu.
I think its a compiler error...And its occured bcoz u have not imported javax.servlet.jsp.tagext.Tag. all the implicit return types like EVAL_BODY_INCLUDE , etc. are final variables of this interface....Hope this helps.
[ January 26, 2005: Message edited by: Nischal Tanna ]
 
Ritu varada
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have imported the TagSupport class which should be enough. Anyway, I tried importing the Tag interface too. Its still giving me a compiler error. I am so frustated...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just tried your code and it compiles for me.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
Ritu varada
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm..I rearranged some of the jar files in my classpath and the code compiled! Thanks, Ben! Next time, I will just have to make my mind work in more directions than just posting immediately. Thanks for all your help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic