Subversion Repositories bacoAlunos

Rev

Rev 1306 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package pt.estgp.estgweb.web.tags;

import org.apache.log4j.Logger;
import org.apache.commons.httpclient.util.URIUtil;
import org.apache.commons.httpclient.URIException;

import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.http.HttpServletRequest;

import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.web.filters.UrlStatFilter;

public class PageUrlStatTag extends BodyTagSupport
{

    private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(PageUrlStatTag.class);

    private 1.5.0/docs/api/java/lang/String.html">String attributes;

    public 1.5.0/docs/api/java/lang/String.html">String getAttributes()
    {
        return attributes;
    }

    public void setAttributes(1.5.0/docs/api/java/lang/String.html">String attributes)
    {
        this.attributes = attributes;
    }

    public int doStartTag() throws JspException
    {
        return EVAL_BODY_TAG;
    }
    public int doEndTag() throws JspException
    {
        HttpServletRequest hrequest = (HttpServletRequest) pageContext.getRequest();
        1.5.0/docs/api/java/lang/String.html">String relativePath = (1.5.0/docs/api/java/lang/String.html">String) hrequest.getAttribute(Globals.ACTUAL_RELATIVE_PATH);

        for(1.5.0/docs/api/java/lang/String.html">String ignore: UrlStatFilter.URL_STAT_IGNORE_PREFIXS)
        {
            if(relativePath.startsWith(ignore))
            {
                return EVAL_PAGE;
            }
        }

        try
        {
            if(attributes == null)
                attributes = "";

            1.5.0/docs/api/java/lang/String.html">String url = "<a " + attributes + " href=\"" + hrequest.getContextPath() + "/urlstat/startUrlStat.do?relativePaths[0].value=" + URIUtil.encodeWithinQuery(relativePath,"ISO-8859-1") + "\">";
            1.5.0/docs/api/java/lang/String.html">String endUrl = "</a>";
            1.5.0/docs/api/java/lang/String.html">String toPage = bodyContent.getString().trim();
            JspWriter writer = pageContext.getOut();
            try
            {
                writer.write(url + toPage + endUrl);
            }
            catch(1.5.0/docs/api/java/lang/Exception.html">Exception e)
            {
                logger.error(e,e);
                throw new JspException(e);
            }
        }
        catch (1.5.0/docs/api/javax/print/URIException.html">URIException e)
        {
            logger.error(e,e);
            throw new JspException(e);
        }



        // Continue processing this page
        return EVAL_PAGE;
    }

    public static void main(1.5.0/docs/api/java/lang/String.html">String[] args)
    {
       
    }


}