Reusable Java library of general tools with minimal external dependencies.
For questions or support, please contact us:
Email: support@aoindustries.com
Phone: 1-800-519-9541
Phone: +1-251-607-9556
Web: https://www.aoindustries.com/contact
public class ServletUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
METHOD_DELETE |
static String |
METHOD_GET |
static String |
METHOD_HEAD |
static String |
METHOD_OPTIONS |
static String |
METHOD_POST |
static String |
METHOD_PUT |
static String |
METHOD_TRACE |
| Modifier and Type | Method and Description |
|---|---|
static <S extends HttpServlet> |
doOptions(HttpServletResponse response,
Class<S> stopClass,
Class<? extends S> thisClass,
String doGet,
String doPost,
String doPut,
String doDelete,
Class<?>[] paramTypes)
A reusable doOptions implementation for servlets.
|
static String |
getAbsolutePath(HttpServletRequest request,
String path) |
static String |
getAbsolutePath(String servletPath,
String relativeUrlPath)
Converts a possibly-relative path to a context-relative absolute path.
|
static String |
getAbsoluteURL(HttpServletRequest request,
String relPath) |
static void |
getAbsoluteURL(HttpServletRequest request,
String relPath,
Appendable out)
Gets an absolute URL for the given context-relative path.
|
static void |
getAbsoluteURL(HttpServletRequest request,
String relPath,
Encoder encoder,
Appendable out)
Gets an absolute URL for the given context-relative path.
|
static Method[] |
getAllDeclaredMethods(Class<?> stopClass,
Class<?> c) |
static String |
getContextRequestUri(HttpServletRequest request)
Gets the current request URI in context-relative form.
|
static String |
getRedirectLocation(HttpServletRequest request,
HttpServletResponse response,
String servletPath,
String href)
Gets the absolute URL that should be used for a redirect.
|
static String |
getRequestEncoding(ServletRequest request)
Gets the request encoding or ISO-8859-1 when not available.
|
static URL |
getResource(ServletContext servletContext,
HttpServletRequest request,
String relativeUrlPath)
Deprecated.
Use regular methods directly
|
static URL |
getResource(ServletContext servletContext,
String path)
Deprecated.
Use regular methods directly
|
static boolean |
isGooglebot(HttpServletRequest request)
Determines if the requestor is Googlebot as described at:
http://www.google.com/support/webmasters/bin/answer.py?answer=80553
|
static boolean |
resourceExists(ServletContext servletContext,
HttpServletRequest request,
String relativeUrlPath)
Deprecated.
Use regular methods directly
|
static boolean |
resourceExists(ServletContext servletContext,
String path)
Deprecated.
Use regular methods directly
|
static void |
sendRedirect(HttpServletRequest request,
HttpServletResponse response,
String href,
int status)
Sends a redirect with relative paths determined from the request servlet path.
|
static void |
sendRedirect(HttpServletResponse response,
String location,
int status)
Sends a redirect to the provided absolute URL location.
|
public static final String METHOD_DELETE
public static final String METHOD_HEAD
public static final String METHOD_GET
public static final String METHOD_OPTIONS
public static final String METHOD_POST
public static final String METHOD_PUT
public static final String METHOD_TRACE
public static String getRequestEncoding(ServletRequest request)
public static String getAbsolutePath(String servletPath, String relativeUrlPath) throws MalformedURLException
servletPath - Required when path might be altered.MalformedURLExceptionpublic static String getAbsolutePath(HttpServletRequest request, String path) throws MalformedURLException
MalformedURLExceptiongetAbsolutePath(java.lang.String, java.lang.String)@Deprecated public static URL getResource(ServletContext servletContext, String path) throws MalformedURLException
null if no resource
is mapped to the path.@Deprecated public static URL getResource(ServletContext servletContext, HttpServletRequest request, String relativeUrlPath) throws MalformedURLException
null if no resource
is mapped to the path.@Deprecated public static boolean resourceExists(ServletContext servletContext, String path) throws MalformedURLException
@Deprecated public static boolean resourceExists(ServletContext servletContext, HttpServletRequest request, String relativeUrlPath) throws MalformedURLException
public static boolean isGooglebot(HttpServletRequest request)
public static String getAbsoluteURL(HttpServletRequest request, String relPath)
public static void getAbsoluteURL(HttpServletRequest request, String relPath, Appendable out) throws IOException
IOExceptionpublic static void getAbsoluteURL(HttpServletRequest request, String relPath, Encoder encoder, Appendable out) throws IOException
IOExceptionpublic static String getRedirectLocation(HttpServletRequest request, HttpServletResponse response, String servletPath, String href) throws MalformedURLException, UnsupportedEncodingException
href - The absolute, context-relative, or page-relative path to redirect to.
The following actions are performed on the provided href:
MalformedURLExceptionUnsupportedEncodingExceptionsendRedirect(javax.servlet.http.HttpServletResponse, java.lang.String, int)public static void sendRedirect(HttpServletResponse response, String location, int status) throws IllegalStateException, IOException
public static void sendRedirect(HttpServletRequest request, HttpServletResponse response, String href, int status) throws IllegalStateException, IOException
IllegalStateExceptionIOExceptionfor transformations applied to the hrefpublic static String getContextRequestUri(HttpServletRequest request)
public static <S extends HttpServlet> void doOptions(HttpServletResponse response, Class<S> stopClass, Class<? extends S> thisClass, String doGet, String doPost, String doPut, String doDelete, Class<?>[] paramTypes)
Copyright © 2000–2016 AO Industries, Inc.. All rights reserved.