tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nuttall, Chris" <Chris.Nutt...@intervoice-brite.co.uk>
Subject Tag to replace <% String counter = "counter" %> in JSP...???
Date Tue, 25 Jul 2000 16:19:23 GMT
Hi,

Is it possible for a custom tag to declare/initialise
variables within the tag handler class, to replace
<% String counter = "counter" %> from within a
JSP page?

Perhaps...

import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;


/**
 * SetCounterTag adds String variable to page scope.
 */
public class SetCounterTag extends TagSupport {

    public int doStartTag() throws JspException {

	// String to be added
	String counter = "counter";

	pageContext.setAttribute("counter", counter);

	// Continue processing this page
	return (EVAL_PAGE);
    }
}


...which could be included within the JSP as:

<tag:setCounter />

...and then access counter later in the JSP page, or
from within another custom tag...???

Regards,


Chris

Mime
View raw message