struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Graham" <dgraham1...@hotmail.com>
Subject Re: cvs commit: jakarta-struts/src/share/org/apache/struts/util RequestUtils.java
Date Sun, 02 Mar 2003 00:58:04 GMT
How is it any different than the way it was implemented before?  If it 
doesn't find the 1.4 method it uses the 1.3 method.

David



>From: "Craig R. McClanahan" <craigmcc@apache.org>
>Reply-To: "Struts Developers List" <struts-dev@jakarta.apache.org>
>To: Struts Developers List <struts-dev@jakarta.apache.org>
>Subject: Re: cvs commit: jakarta-struts/src/share/org/apache/struts/util 
>RequestUtils.java
>Date: Sat, 1 Mar 2003 16:42:21 -0800 (PST)
>
>
>
>On Sat, 2 Mar 2003 dgraham@apache.org wrote:
>
> > Date: 2 Mar 2003 00:22:40 -0000
> > From: dgraham@apache.org
> > Reply-To: Struts Developers List <struts-dev@jakarta.apache.org>
> > To: jakarta-struts-cvs@apache.org
> > Subject: cvs commit: jakarta-struts/src/share/org/apache/struts/util
> >     RequestUtils.java
> >
> > dgraham     2003/03/01 16:22:40
> >
> >   Modified:    src/share/org/apache/struts/util RequestUtils.java
> >   Log:
> >   Change encodeURL to not use reflection on every call.
> >
>
>Note that this change imposes a 1.4 dependency to build Struts.  That
>would be OK with *me* (since I use 1.4 all the time), but may not be OK
>with other folks.
>
>Craig
>
>
> >   Revision  Changes    Path
> >   1.91      +26 -15    
>jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java
> >
> >   Index: RequestUtils.java
> >   ===================================================================
> >   RCS file: 
>/home/cvs/jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java,v
> >   retrieving revision 1.90
> >   retrieving revision 1.91
> >   diff -u -r1.90 -r1.91
> >   --- RequestUtils.java	26 Feb 2003 04:48:56 -0000	1.90
> >   +++ RequestUtils.java	2 Mar 2003 00:22:40 -0000	1.91
> >   @@ -142,6 +142,24 @@
> >         * The context attribute under which we store our prefixes list.
> >         */
> >        private static final String PREFIXES_KEY = 
>"org.apache.struts.util.PREFIXES";
> >   +
> >   +    /**
> >   +     * Java 1.4 encode method to use instead of deprecated 1.3 
>version.
> >   +     */
> >   +    private static Method encode = null;
> >   +
> >   +    /**
> >   +     * Initialize the encode variable with the 1.4 method if 
>available
> >   +     */
> >   +    static {
> >   +        try {
> >   +            // get version of encode method with two String args
> >   +            Class[] args = new Class[] { String.class, String.class 
>};
> >   +            encode = URLEncoder.class.getMethod("encode", args);
> >   +        } catch (NoSuchMethodException e) {
> >   +            log.debug("Could not find Java 1.4 encode method.  Using 
>deprecated version.", e);
> >   +        }
> >   +    }
> >
> >        // --------------------------------------------------------- 
>Public Methods
> >
> >   @@ -1904,27 +1922,20 @@
> >         * @return String - the encoded url.
> >         */
> >        public static String encodeURL(String url) {
> >   -        // default to old version
> >   -        String encodedURL = URLEncoder.encode(url);
> >   -        Class encoderClass = URLEncoder.class;
> >   -
> >            try {
> >   -            // get version of encode method with two String args
> >   -            Class[] args = new Class[] { String.class, String.class 
>};
> >   -            Method encode = encoderClass.getMethod("encode", args);
> >
> >                // encode url with new 1.4 method and UTF-8 encoding
> >   -            encodedURL = (String) encode.invoke(null, new Object[] { 
>url, "UTF-8" });
> >   +            if (encode != null) {
> >   +                return (String) encode.invoke(null, new Object[] { 
>url, "UTF-8" });
> >   +            }
> >
> >            } catch (IllegalAccessException e) {
> >                log.debug("Could not find Java 1.4 encode method.  Using 
>deprecated version.", e);
> >            } catch (InvocationTargetException e) {
> >                log.debug("Could not find Java 1.4 encode method. Using 
>deprecated version.", e);
> >   -        } catch (NoSuchMethodException e) {
> >   -            log.debug("Could not find Java 1.4 encode method.  Using 
>deprecated version.", e);
> >            }
> >
> >   -        return encodedURL;
> >   +        return URLEncoder.encode(url);
> >        }
> >
> >    }
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> >
> >
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-dev-help@jakarta.apache.org


_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Mime
View raw message