Forums Register Login

compilation error for EVAL_BODY_AGAIN

+Pie Number of slices to send: Send
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 ?
+Pie Number of slices to send: Send
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!
+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
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...
+Pie Number of slices to send: Send
I just tried your code and it compiles for me.
+Pie Number of slices to send: Send
Check your classpath again
+Pie Number of slices to send: Send
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.
World domination requires a hollowed out volcano with good submarine access. Tiny ads are optional.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1935 times.
Similar Threads
doStartTag()
Classic Tag Handler
Classic tag error
Classic Tag Handler
Problem in compiling Class tag handler
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 23:47:51.