FileDocCategorySizeDatePackage
ShowCounterTag.javaAPI DocExample1816Thu Jun 28 16:14:16 BST 2001com.ora.jsp.tags.counter

ShowCounterTag

public class ShowCounterTag extends TagSupport
This class is a custom action for showing the current value of a page counter for the page where it's included.
author
Hans Bergsten, Gefion software
version
1.0.1

Fields Summary
private int
scope
Constructors Summary
Methods Summary
public intdoEndTag()
Gets the CounterBean from the specified scope and writes the value of the counter for the current page to the JspWriter.

        int value = -1;
        CounterBean counters = (CounterBean)
            pageContext.getAttribute("com.ora.counter", scope);
        HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
        String uri = req.getRequestURI();
        if (counters != null) {
            value = counters.getCurrentValue(uri);
        }
        try {
            pageContext.getOut().println(value);
        }
        catch (IOException e) {} // Ignore it
    	return EVAL_PAGE;
    
public voidsetScope(java.lang.String scopeName)
Sets the scope attribute value.

param
scopeName the scope for the counter.

        if ("application".equals(scopeName)) {
            scope = PageContext.APPLICATION_SCOPE;
        }
        else if ("session".equals(scopeName)) {
            scope = PageContext.SESSION_SCOPE;
        }
        else if ("request".equals(scopeName)) {
            scope = PageContext.REQUEST_SCOPE;
        }
        else if ("page".equals(scopeName)) {
            scope = PageContext.PAGE_SCOPE;
        }