cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sean Gould <sean.go...@fluid-code.com>
Subject BUG: org.apache.cocoon.processor.xslt.XSLTProcessor:filterParameters(HttpServlet Request request)
Date Mon, 05 Nov 2001 16:42:42 GMT
Greetings,

New to the list and relatively new to cocoon. I've been using Cocoon 1.8.2
and have encountered the following problem in the filterParameters method of
the XSLTProcessor.

The code, as it stands, attempts to put request/cookie/headers name/value
pairs into a hashtable. Under my development environment running Cocoon
through Resin, some browsers on the Macintosh platform (I've tested using
Netscape 4.x, and Explorer 5 versions), have a null value for some of their
headers.

Since hashtables can not accept null elements as a value, an exception is
thrown when trying to put the null value into the hashtable.

I've patched my local version to check for null values before putting them
into the hashtable. Code follows:

private Hashtable filterParameters(HttpServletRequest request) {
        Hashtable params = new Hashtable();
        Enumeration parameters = request.getParameterNames();

        if (parameters != null) {
            while (parameters.hasMoreElements()) {
                String name = (String) parameters.nextElement();
                if (isValidName (name)){
                    Object value = request.getParameter(name);
                    if (value != null){
                        params.put (name, value);
                    }
                }
            }
        }

        Cookie[] cookies = request.getCookies ();
        if (cookies != null) {
            for (int i = 0; i < cookies.length; i++) {
                Cookie cookie = cookies [i];
                String name = cookie.getName ();
                if (isValidName (name)){
                    Object value = cookie.getValue();
                    if (value != null){
                        params.put ("C_" + name, value);
                    }
                }
            }
        }
        
        Enumeration headers = request.getHeaderNames ();
        if (headers != null) {
          while (headers.hasMoreElements ()) {
            String name = (String) headers.nextElement ();
            if (isValidName (name)){
                Object value = request.getHeader(name);
                if (value != null){
                    params.put ("R_" + name, value);
                }
            }
          }
        }

        return params;
    }

Sean Gould
sean.gould@fluid-code.com
http://www.fluid-code.com


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message