FileDocCategorySizeDatePackage
EncodeURLTag.javaAPI DocExample3244Thu Jun 28 16:14:16 BST 2001com.ora.jsp.tags.generic

EncodeURLTag

public class EncodeURLTag extends TagSupport implements ParamParent
This class is a custom action for encoding URLs for URL rewriting (session tracking) with possible parameter values URL encoded.
author
Hans Bergsten, Gefion software
version
1.0

Fields Summary
private String
url
private Vector
params
Constructors Summary
Methods Summary
public intdoEndTag()
Appends possible URL encoded parameters to the main URL, encodes the result for URL rewriting and writes the result to the JspWriter.

        StringBuffer encodedURL = new StringBuffer(url);
        if (params != null && params.size() > 0) {
            encodedURL.append('?");
            boolean isFirst = true;
            Enumeration e = params.elements();
            while (e.hasMoreElements()) {
                Param p = (Param) e.nextElement();
                if (!isFirst) {
                    encodedURL.append('&");
                }
                encodedURL.append(p.getName()).append('=").
                    append(p.getValue());
                isFirst = false;
            }
        }
        try {
            HttpServletResponse res = 
                (HttpServletResponse) pageContext.getResponse();
            JspWriter out = pageContext.getOut();
            out.print(res.encodeURL(encodedURL.toString()));
        }
        catch (IOException e) {}
        return EVAL_PAGE;
    
public intdoStartTag()
Override the default implementation so that possible param actions in the body are processed.

        // Reset per-use state set by nested elements
        params = null;

        return EVAL_BODY_INCLUDE;
    
public voidrelease()
Releases all instance variables.

        url = null;
        params = null;
        super.release();
    
public voidsetParam(java.lang.String name, java.lang.String value)
Adds a parameter name and value. This method is called by param tags in the action body.

param
name the parameter name
param
value the URL encoded parameter value

        if (params == null) {
            params = new Vector();
        }
        Param param = new Param(name, value);
        params.addElement(param);
    
public voidsetUrl(java.lang.String url)
Sets the url attribute.

param
url the page URL value

        this.url = url;