Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
14.8 Using Nested Tags
345
Listing 14.23 IfTag.java
package coreservlets.tags;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
import javax.servlet.*;
/** A tag that acts like an if/then/else.
*/
public class IfTag extends TagSupport {
private boolean condition;
private boolean hasCondition = false;
public void setCondition(boolean condition) {
this.condition = condition;
hasCondition = true;
}
public boolean getCondition() {
return(condition);
}
public void setHasCondition(boolean flag) {
this.hasCondition = flag;
}
/** Has the condition field been explicitly set? */
public boolean hasCondition() {
return(hasCondition);
}
public int doStartTag() {
return(EVAL_BODY_INCLUDE);
}
}
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved