|
DLESE Tools v1.6.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.dlese.dpc.webapps.tools.GeneralServletTools
public final class GeneralServletTools
This class contains utility methods useful in servlet-based applications.
| Constructor Summary | |
|---|---|
GeneralServletTools()
|
|
| Method Summary | |
|---|---|
static String |
getAbsolutePath(String fname,
ServletContext servletContext)
Gets the absolute path to a given file or directory. |
static String |
getAbsolutePath(String fname,
String docRoot)
Gets the absolute path to a given file or directory. |
static String |
getContextPath(ServletContext servletContext)
Returns the context path for the webapp, for example '/dds' or '/' for the root context. |
static String |
getContextUrl(HttpServletRequest req)
Gets the URL that refers to the current server and servlet context, for example "http://www.dlese.org/dds" or "http://domain.org:8080/context" or or "http://localhost:8080/context". |
static String |
getQueryString(HttpServletRequest request)
Gets the query string supplied in the request, for example "q=ocean&s=0&n=10". |
static String |
getRequestURI(HttpServletRequest req)
Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request. |
static StringBuffer |
getRequestURL(HttpServletRequest req)
Reconstructs the URL the client used to make the request, even if the page has been forwarded for example via struts (action.do). |
static String |
getServerUrl(HttpServletRequest req)
Gets the URL that refers to the current server (scheme, hostname and port), for example "http://www.dlese.org" or "http://host:8080" or "http://localhost:8080". |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GeneralServletTools()
| Method Detail |
|---|
public static String getContextPath(ServletContext servletContext)
servletContext - The ServletContext object for the webapp
public static String getServerUrl(HttpServletRequest req)
req - The request.
public static String getContextUrl(HttpServletRequest req)
req - The request.
public static String getQueryString(HttpServletRequest request)
HttpServletRequest.getQueryString(), but works even if the request has been
forwarded.
request - The request
public static StringBuffer getRequestURL(HttpServletRequest req)
req - The request.
public static String getRequestURI(HttpServletRequest req)
req - The request.
public static final String getAbsolutePath(String fname,
ServletContext servletContext)
throws ServletException
If the string that is passed in already begings with "/", nothing is done.
Note: the HttpServlet init() (super.init()) method must be called prior to using this method, else a ServletException is thrown.
fname - An absolute or relative file name or path (relative the the context root).servletContext - The HttpServletContext of the appliection.
ServletException - An exception related to this servlet
public static final String getAbsolutePath(String fname,
String docRoot)
If the string that is passed in already begings with "/", nothing is done.
Note: the super.init() method must be called prior to using this method, else a ServletException is thrown.
fname - An absolute or relative file name or path (relative the the context root).docRoot - The context document root as obtained by calling getServletContext().getRealPath("/");
|
DLESE Tools v1.6.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||