Package com.appslandia.plum.utils
Class ServletUtils
- java.lang.Object
-
- com.appslandia.plum.utils.ServletUtils
-
-
Field Summary
Fields Modifier and Type Field Description static StringACTION_INDEXstatic StringCOOKIE_CLIENT_ZONE_IDstatic StringPARAM_RETURN_URLstatic StringPARAM_SERVER_NAMEstatic StringREQUEST_ATTRIBUTE_MODEL
-
Constructor Summary
Constructors Constructor Description ServletUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringBuilderabsUrlBase(javax.servlet.http.HttpServletRequest request, String serverName)static voidaddError(javax.servlet.http.HttpServletRequest request, String fieldName, String msgKey)static voidaddError(javax.servlet.http.HttpServletRequest request, String fieldName, String msgKey, Map<String,Object> msgParams)static booleanallowContentType(String contentType, String allowType)static StringBuilderappendUriQuery(javax.servlet.http.HttpServletRequest request, StringBuilder sb)static javax.servlet.http.HttpServletResponseassertNotCommitted(javax.servlet.http.HttpServletResponse response)static booleancheckNotModified(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, long lastModifiedMs)static booleancheckNotModified(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String etag)static booleancheckPrecondition(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, long lastModifiedMs)static booleancheckPrecondition(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String etag)static voidforward(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String path)static StringgetAppDir(javax.servlet.ServletContext sc)static <T> TgetAppScoped(javax.servlet.http.HttpServletRequest request, Class<T> beanType)static <T> TgetAppScoped(javax.servlet.ServletContext sc, Class<T> beanType)static PrintWritergetBOMWriter(javax.servlet.http.HttpServletResponse response)static StringBuildergetClientBuilder(javax.servlet.http.HttpServletRequest request, StringBuilder builder)static StringgetClientIp(javax.servlet.http.HttpServletRequest request)static ZoneOffsetgetClientZone(javax.servlet.http.HttpServletRequest request)static StringgetCookiePath(javax.servlet.ServletContext sc)static StringgetCookieValue(javax.servlet.http.HttpServletRequest request, String name)static com.appslandia.common.base.FormatProvidergetFormatProvider(javax.servlet.http.HttpServletRequest request)static StringgetInitParam(javax.servlet.FilterConfig config, String paramName, String defaultValue)static StringgetInitParam(javax.servlet.ServletConfig config, String paramName, String defaultValue)static StringgetInitParam(javax.servlet.ServletContext sc, String paramName, String defaultValue)static StringBuildergetLoginUrl(javax.servlet.http.HttpServletRequest request)static MessagesgetMessages(javax.servlet.http.HttpServletRequest request)static ModelStategetModelState(javax.servlet.http.HttpServletRequest request)static ObjectgetMutex(javax.servlet.http.HttpSession session)static ObjectgetMutex(javax.servlet.ServletContext context)static PrefCookiegetPrefCookie(javax.servlet.http.HttpServletRequest request)static PrintWritergetPrintWriter(javax.servlet.http.HttpServletResponse response)static RequestContextgetRequestContext(javax.servlet.http.HttpServletRequest request)static javax.servlet.RequestDispatchergetRequestDispatcher(javax.servlet.http.HttpServletRequest request, String path)static StringgetRequestUrl(javax.servlet.http.HttpServletRequest request)static StringgetRequestUrl(javax.servlet.http.HttpServletRequest request, String pathLang)static UserPrincipalgetRequiredPrincipal(javax.servlet.http.HttpServletRequest request)static ResourcesgetResources(javax.servlet.http.HttpServletRequest request)static TempDatagetTempData(javax.servlet.http.HttpServletRequest request)static StringgetUriQuery(javax.servlet.http.HttpServletRequest request)static UserPrincipalgetUserPrincipal(javax.servlet.http.HttpServletRequest request)static WritergetWriter(javax.servlet.http.HttpServletResponse response)static voidinclude(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String path)static booleanisAjaxRequest(javax.servlet.http.HttpServletRequest request)static booleanisGzipAccepted(javax.servlet.http.HttpServletRequest request)static booleanisLocalhost(String serverName)static booleanloadProps(javax.servlet.ServletContext sc, String resourcePath, com.appslandia.common.base.PropertyConfig config)static booleanloadProps(javax.servlet.ServletContext sc, String resourcePath, Properties props)static StringBuildernewUrlBuilder()static StringparseLanguage(javax.servlet.http.HttpServletRequest request, Collection<String> supportedLanguages)static ObjectremoveAttribute(javax.servlet.http.HttpServletRequest request, String attribute)static voidremoveCookie(javax.servlet.http.HttpServletResponse response, String name, String domain, String path)static voidsendRedirect(javax.servlet.http.HttpServletResponse response, String location, int status)static voidsetContentDisposition(javax.servlet.http.HttpServletResponse response, String fileName, boolean inline)static voidsetWWWAuthenticate(javax.servlet.http.HttpServletResponse response, String authType, String realmName)static StringtoEtag(byte[] md5)static StringtoEtag(Object... args)static StringtoWrapperPath(javax.servlet.http.HttpServletRequest request)static StringtoWrapperPath(javax.servlet.http.HttpServletResponse response)static <T> TunwrapRequest(javax.servlet.http.HttpServletRequest request, Class<T> toImpl)static <T> TunwrapResponse(javax.servlet.http.HttpServletResponse response, Class<T> toImpl)
-
-
-
Field Detail
-
ACTION_INDEX
public static final String ACTION_INDEX
- See Also:
- Constant Field Values
-
REQUEST_ATTRIBUTE_MODEL
public static final String REQUEST_ATTRIBUTE_MODEL
- See Also:
- Constant Field Values
-
PARAM_RETURN_URL
public static final String PARAM_RETURN_URL
- See Also:
- Constant Field Values
-
PARAM_SERVER_NAME
public static final String PARAM_SERVER_NAME
- See Also:
- Constant Field Values
-
COOKIE_CLIENT_ZONE_ID
public static final String COOKIE_CLIENT_ZONE_ID
- See Also:
- Constant Field Values
-
-
Method Detail
-
newUrlBuilder
public static StringBuilder newUrlBuilder()
-
getUriQuery
public static String getUriQuery(javax.servlet.http.HttpServletRequest request)
-
appendUriQuery
public static StringBuilder appendUriQuery(javax.servlet.http.HttpServletRequest request, StringBuilder sb)
-
getLoginUrl
public static StringBuilder getLoginUrl(javax.servlet.http.HttpServletRequest request)
-
absUrlBase
public static StringBuilder absUrlBase(javax.servlet.http.HttpServletRequest request, String serverName)
-
getRequestUrl
public static String getRequestUrl(javax.servlet.http.HttpServletRequest request)
-
getRequestUrl
public static String getRequestUrl(javax.servlet.http.HttpServletRequest request, String pathLang)
-
getClientBuilder
public static StringBuilder getClientBuilder(javax.servlet.http.HttpServletRequest request, StringBuilder builder)
-
getClientIp
public static String getClientIp(javax.servlet.http.HttpServletRequest request)
-
isLocalhost
public static boolean isLocalhost(String serverName) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
getAppDir
public static String getAppDir(javax.servlet.ServletContext sc)
-
isGzipAccepted
public static boolean isGzipAccepted(javax.servlet.http.HttpServletRequest request)
-
isAjaxRequest
public static boolean isAjaxRequest(javax.servlet.http.HttpServletRequest request)
-
setContentDisposition
public static void setContentDisposition(javax.servlet.http.HttpServletResponse response, String fileName, boolean inline)
-
parseLanguage
public static String parseLanguage(javax.servlet.http.HttpServletRequest request, Collection<String> supportedLanguages)
-
getMutex
public static Object getMutex(javax.servlet.http.HttpSession session)
-
getMutex
public static Object getMutex(javax.servlet.ServletContext context)
-
getWriter
public static Writer getWriter(javax.servlet.http.HttpServletResponse response) throws IOException
- Throws:
IOException
-
getPrintWriter
public static PrintWriter getPrintWriter(javax.servlet.http.HttpServletResponse response) throws IOException
- Throws:
IOException
-
getBOMWriter
public static PrintWriter getBOMWriter(javax.servlet.http.HttpServletResponse response) throws IOException, IllegalStateException
- Throws:
IOExceptionIllegalStateException
-
assertNotCommitted
public static javax.servlet.http.HttpServletResponse assertNotCommitted(javax.servlet.http.HttpServletResponse response) throws IllegalStateException- Throws:
IllegalStateException
-
getRequestDispatcher
public static javax.servlet.RequestDispatcher getRequestDispatcher(javax.servlet.http.HttpServletRequest request, String path)
-
forward
public static void forward(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String path) throws javax.servlet.ServletException, IOException- Throws:
javax.servlet.ServletExceptionIOException
-
include
public static void include(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String path) throws javax.servlet.ServletException, IOException- Throws:
javax.servlet.ServletExceptionIOException
-
sendRedirect
public static void sendRedirect(javax.servlet.http.HttpServletResponse response, String location, int status) throws IllegalStateException- Throws:
IllegalStateException
-
toWrapperPath
public static String toWrapperPath(javax.servlet.http.HttpServletRequest request)
-
toWrapperPath
public static String toWrapperPath(javax.servlet.http.HttpServletResponse response)
-
unwrapRequest
public static <T> T unwrapRequest(javax.servlet.http.HttpServletRequest request, Class<T> toImpl)
-
unwrapResponse
public static <T> T unwrapResponse(javax.servlet.http.HttpServletResponse response, Class<T> toImpl)
-
getCookieValue
public static String getCookieValue(javax.servlet.http.HttpServletRequest request, String name)
-
removeCookie
public static void removeCookie(javax.servlet.http.HttpServletResponse response, String name, String domain, String path)
-
getCookiePath
public static String getCookiePath(javax.servlet.ServletContext sc)
-
getClientZone
public static ZoneOffset getClientZone(javax.servlet.http.HttpServletRequest request)
-
toEtag
public static String toEtag(byte[] md5)
-
checkNotModified
public static boolean checkNotModified(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, long lastModifiedMs)
-
checkNotModified
public static boolean checkNotModified(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String etag)
-
checkPrecondition
public static boolean checkPrecondition(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, long lastModifiedMs)
-
checkPrecondition
public static boolean checkPrecondition(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String etag)
-
getUserPrincipal
public static UserPrincipal getUserPrincipal(javax.servlet.http.HttpServletRequest request)
-
getRequiredPrincipal
public static UserPrincipal getRequiredPrincipal(javax.servlet.http.HttpServletRequest request)
-
setWWWAuthenticate
public static void setWWWAuthenticate(javax.servlet.http.HttpServletResponse response, String authType, String realmName)
-
removeAttribute
public static Object removeAttribute(javax.servlet.http.HttpServletRequest request, String attribute)
-
getInitParam
public static String getInitParam(javax.servlet.FilterConfig config, String paramName, String defaultValue)
-
getInitParam
public static String getInitParam(javax.servlet.ServletConfig config, String paramName, String defaultValue)
-
getInitParam
public static String getInitParam(javax.servlet.ServletContext sc, String paramName, String defaultValue)
-
getRequestContext
public static RequestContext getRequestContext(javax.servlet.http.HttpServletRequest request)
-
getModelState
public static ModelState getModelState(javax.servlet.http.HttpServletRequest request)
-
getMessages
public static Messages getMessages(javax.servlet.http.HttpServletRequest request)
-
getTempData
public static TempData getTempData(javax.servlet.http.HttpServletRequest request)
-
getPrefCookie
public static PrefCookie getPrefCookie(javax.servlet.http.HttpServletRequest request)
-
getResources
public static Resources getResources(javax.servlet.http.HttpServletRequest request)
-
getFormatProvider
public static com.appslandia.common.base.FormatProvider getFormatProvider(javax.servlet.http.HttpServletRequest request)
-
addError
public static void addError(javax.servlet.http.HttpServletRequest request, String fieldName, String msgKey)
-
addError
public static void addError(javax.servlet.http.HttpServletRequest request, String fieldName, String msgKey, Map<String,Object> msgParams)
-
getAppScoped
public static <T> T getAppScoped(javax.servlet.http.HttpServletRequest request, Class<T> beanType)
-
getAppScoped
public static <T> T getAppScoped(javax.servlet.ServletContext sc, Class<T> beanType)
-
loadProps
public static boolean loadProps(javax.servlet.ServletContext sc, String resourcePath, Properties props) throws IOException- Throws:
IOException
-
loadProps
public static boolean loadProps(javax.servlet.ServletContext sc, String resourcePath, com.appslandia.common.base.PropertyConfig config) throws IOException- Throws:
IOException
-
-