FileDocCategorySizeDatePackage
URLPattern.javaAPI DocGlassfish v2 API3488Fri May 04 22:35:32 BST 2007com.sun.enterprise.util.web

URLPattern

public class URLPattern extends Object

Fields Summary
private static final int
NL
private static final int
CR
Constructors Summary
Methods Summary
public static booleanisValid(java.lang.String urlPattern)
This method is used to check the validity of url pattern according to the spec. It is used in the following places: 1. in WebResourceCollection 2. in ServletMapping 3. in ServletFilterMapping (above three see Servlet Spec, from version 2.3 on, Secion 13.2: "Rules for Processing the Deployment Descriptor") 4. in jsp-property-group (see JSP.3.3: "JSP Property Groups")

param
urlPattern the url pattern
return
false for invalid url pattern


                                                                                           
         
        // URL Pattern should not contain New Line (NL) or
        // Carriage Return (CR)
        if (urlPattern.indexOf(NL) != -1  || urlPattern.indexOf (CR) != -1) {
            return false;
        }

        // Check validity for extension mapping
        if (urlPattern.startsWith("*.")) {
            if (urlPattern.indexOf('/") < 0) {
                return true;
            } else {
                return false;
            }
        }

        // check validity for path mapping
        if ( urlPattern.startsWith("/") && urlPattern.indexOf("*.") < 0) {
            return true;
        } else {
            return false;
        }