com.v5analytics.webster.utils.UrlUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of webster Show documentation
Show all versions of webster Show documentation
Minimalist web framework, that has an express.js like API.
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();
}
}