java.lang.Objectorg.objectweb.telosys.util.web.WebUtil
Utility class for Web operations ( set of static methods )
Method Summary | |
static boolean |
checkExistence(javax.servlet.ServletContext servletContext,
java.lang.String sResourcePath)
Check the existence of the given resource in the given servlet context |
static void |
error(javax.servlet.http.HttpServletResponse response,
java.lang.String sMsg)
Generates a "text/html" response page with a "body" containing "ERROR" + the given message |
static void |
error(javax.servlet.http.HttpServletResponse response,
java.lang.String sMsg,
java.util.ListIterator iter)
Generates a "text/html" response page with a "body" containing the given message and one line for each item of the iterator |
static boolean |
forward(java.lang.String sUrl,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Uses the "request dispatcher" to forward a request |
static java.lang.String |
getContextResourceURI(javax.servlet.http.HttpServletRequest request,
java.lang.String sResourcePath)
Returns the context URI for the given resource path |
static java.lang.String |
getContextResourceURL(javax.servlet.http.HttpServletRequest request,
java.lang.String sResourcePath)
Returns the full "client side" http URL for the given resource path |
static java.lang.String |
getContextRootURI(javax.servlet.http.HttpServletRequest request)
Returns the context root URI for the given request ( e.g. : "/WebAppContext" ) |
static java.lang.String |
getContextRootURL(javax.servlet.http.HttpServletRequest request)
Returns the full context root URL for the given request ( e.g. : "http://server:8080/WebAppContext" ) |
static java.lang.String |
getRootUrl(javax.servlet.http.HttpServletRequest request)
Deprecated. : use getContextRootURL() instead |
static void |
info(javax.servlet.http.HttpServletResponse response,
java.lang.String sMsg)
Generates a "text/html" response page with a "body" containing only the given message |
static void |
msgPage(javax.servlet.http.HttpServletResponse response,
java.lang.String sTitle,
java.lang.String sMsg)
Generates a "text/html" response page with a "body" containing the given title and message |
static void |
noCache(javax.servlet.http.HttpServletResponse response)
Set the HTTP headers to avoid caching |
static boolean |
redirect(java.lang.String sUrl,
javax.servlet.http.HttpServletResponse response)
"HTTP redirection" to an other URL ( HTTP code "302" ) |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static boolean forward(java.lang.String sUrl, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
sUrl
- the target URLrequest
- the request objectresponse
- the response object
javax.servlet.ServletException
- :
java.io.IOException
- :public static boolean redirect(java.lang.String sUrl, javax.servlet.http.HttpServletResponse response)
sUrl
- the target URLresponse
- the response object
public static void noCache(javax.servlet.http.HttpServletResponse response)
response
- public static void info(javax.servlet.http.HttpServletResponse response, java.lang.String sMsg) throws javax.servlet.ServletException, java.io.IOException
response
- the response objectsMsg
- the message to print in the generated page
javax.servlet.ServletException
- :
java.io.IOException
- :public static void error(javax.servlet.http.HttpServletResponse response, java.lang.String sMsg) throws javax.servlet.ServletException, java.io.IOException
response
- :sMsg
- :
javax.servlet.ServletException
- :
java.io.IOException
- :public static void error(javax.servlet.http.HttpServletResponse response, java.lang.String sMsg, java.util.ListIterator iter) throws javax.servlet.ServletException, java.io.IOException
response
- :sMsg
- :iter
- :
javax.servlet.ServletException
- :
java.io.IOException
- :public static void msgPage(javax.servlet.http.HttpServletResponse response, java.lang.String sTitle, java.lang.String sMsg)
response
- sTitle
- the titlesMsg
- the messagepublic static java.lang.String getRootUrl(javax.servlet.http.HttpServletRequest request)
request
-
public static java.lang.String getContextRootURL(javax.servlet.http.HttpServletRequest request)
request
-
public static java.lang.String getContextRootURI(javax.servlet.http.HttpServletRequest request)
request
-
public static java.lang.String getContextResourceURL(javax.servlet.http.HttpServletRequest request, java.lang.String sResourcePath)
request
- sResourcePath
- : the server side context resource path public static java.lang.String getContextResourceURI(javax.servlet.http.HttpServletRequest request, java.lang.String sResourcePath)
request
- sResourcePath
- : the server side context resource path public static boolean checkExistence(javax.servlet.ServletContext servletContext, java.lang.String sResourcePath)
servletContext
- sResourcePath
- the path to the resource, it must begin with a "/"