FileDocCategorySizeDatePackage
IncrementCounterTag.javaAPI DocExample1787Thu Jun 28 16:14:16 BST 2001com.ora.jsp.tags.counter

IncrementCounterTag

public class IncrementCounterTag extends TagSupport
This class is a custom action for incrementing the 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, or creates a new one if it doesn't exist, and increments the value of the counter for the current page.

        CounterBean counters = (CounterBean)
            pageContext.getAttribute("com.ora.counter", scope);
        if (counters == null) {
            counters = new CounterBean();
            pageContext.setAttribute("com.ora.counter", counters, scope);
        }
        HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
        String uri = req.getRequestURI();
        counters.incrementValue(uri);
    	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;
        }