This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JSP and the fly likes compilation error for EVAL_BODY_AGAIN Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "compilation error for EVAL_BODY_AGAIN" Watch "compilation error for EVAL_BODY_AGAIN" New topic
Author

compilation error for EVAL_BODY_AGAIN

Ritu varada
Ranch Hand

Joined: Sep 08, 2004
Posts: 117
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 ?


SCJP,SCWCD(1.4)
Ritu varada
Ranch Hand

Joined: Sep 08, 2004
Posts: 117
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

Joined: Aug 19, 2003
Posts: 182
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 ]

Thnx
Ritu varada
Ranch Hand

Joined: Sep 08, 2004
Posts: 117
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

Joined: Dec 11, 2004
Posts: 13410

I just tried your code and it compiles for me.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Check your classpath again
Ritu varada
Ranch Hand

Joined: Sep 08, 2004
Posts: 117
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compilation error for EVAL_BODY_AGAIN
 
Similar Threads
Classic Tag Handler
doStartTag()
Classic tag error
Problem in compiling Class tag handler
Classic Tag Handler