Following code which is given below is helpful for you to understand JSP tag variables.
Code:
package com.stardeveloper.tag.test;
import java.util.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public final class SecondTag implements Tag {
private PageContext pc = null;
public void setPageContext(PageContext p) {
pc = p;
}
public void setParent(Tag t) {}
public Tag getParent() { return null; }
public int doStartTag() throws JspException {
Calendar cal = Calendar.getInstance();
pc.setAttribute("time", cal.getTime().toString());
return EVAL_BODY_INCLUDE;
}
public int doEndTag() throws JspException {
return EVAL_PAGE;
}
public void release() {
pc = null;
}
}
Bookmarks