All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.v5analytics.webster.utils.UrlUtils Maven / Gradle / Ivy

There is a newer version: 2.3.1
Show newest version
package com.v5analytics.webster.utils;

import com.v5analytics.webster.WebsterException;

import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

public class UrlUtils {
    public static String urlDecode(String s) {
        try {
            return URLDecoder.decode(s, "utf-8");
        } catch (UnsupportedEncodingException e) {
            throw new WebsterException(e);
        }
    }

    public static String urlEncode(String s) {
        try {
            return URLEncoder.encode(s, "utf-8");
        } catch (UnsupportedEncodingException e) {
            throw new WebsterException(e);
        }
    }

    public static String getRootRef(HttpServletRequest request) {
        return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy