Rectangle 27 0

org.apache.commons.validator.UrlValidator and static method isValid(String url) might be of help here.

Note this wouldn't work for any client side GWT as Apache Commons isn't a GWT module..

validation - GWT java URL Validator - Stack Overflow

java validation url gwt
Rectangle 27 0

private RegExp urlValidator;
private RegExp urlPlusTldValidator;
public boolean isValidUrl(String url, boolean topLevelDomainRequired) {
    if (urlValidator == null || urlPlusTldValidator == null) {
        urlValidator = RegExp.compile("^((ftp|http|https)://[\\w@.\\-\\_]+(:\\d{1,5})?(/[\\w#!:.?+=&%@!\\_\\-/]+)*){1}$");
        urlPlusTldValidator = RegExp.compile("^((ftp|http|https)://[\\w@.\\-\\_]+\\.[a-zA-Z]{2,}(:\\d{1,5})?(/[\\w#!:.?+=&%@!\\_\\-/]+)*){1}$");
    }
    return (topLevelDomainRequired ? urlPlusTldValidator : urlValidator).exec(url) != null;
}

@Andy: just wrote a small JUnit and indeed it returns false on google.com/ -- but it does return true on http://google.com/ (with or without trailing slash). According to the definition of URLs, the schema prefix (e.g. 'http') followed by :// is mandatory, thus google.com is invalid.

@Sven Ah, apologies, I was under the impression I was prepending http:// but it's entirely possible that I forgot! (+1)

https://xyz.com/getUser.action?id=1&pwd=2

validation - GWT java URL Validator - Stack Overflow

java validation url gwt