net.sf.mmapps.commons.util
Class HttpUtil

java.lang.Object
  extended by net.sf.mmapps.commons.util.HttpUtil

public class HttpUtil
extends java.lang.Object


Method Summary
static void addNoCacheHeaders(javax.servlet.http.HttpServletResponse response, int expire)
          The code first sets the Expires header to a date in the past.
static java.lang.String determinePathToRoot(javax.servlet.http.HttpServletRequest request, java.lang.String uri)
          Determines the relative path to the root (e.g. ../../..) for the given request.
static java.lang.String getAllRequestInfo(javax.servlet.http.HttpServletRequest request)
           
static java.lang.String getCookieInfo(javax.servlet.http.HttpServletRequest request)
           
static java.lang.String getErrorInfo(javax.servlet.http.HttpServletRequest request, java.lang.Throwable exception, long ticket, java.lang.String version)
           
static java.lang.String getRequestInfo(javax.servlet.http.HttpServletRequest request)
           
static java.lang.String getSecureServerDocRoot(javax.servlet.http.HttpServletRequest request)
          get Secure Server Document Root
static java.lang.String getSecureWebappUri(javax.servlet.http.HttpServletRequest request)
          get Secure WebappUri.
static java.lang.String getServerDocRoot(javax.servlet.http.HttpServletRequest request)
          get Server Document Root
static java.lang.String getSessionInfo(javax.servlet.http.HttpServletRequest request)
           
 java.lang.String getURLContent(java.lang.String urlPath)
          get Remote Content
static java.lang.String getURLContent(java.net.URL url)
          get Remote Content
static java.lang.String getURLContentPost(java.net.URL url, java.lang.String body)
          Post a string to an URL and get the reply as a string.
static java.lang.String getWebappUri(javax.servlet.http.HttpServletRequest request)
          get WebappUri.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addNoCacheHeaders

public static void addNoCacheHeaders(javax.servlet.http.HttpServletResponse response,
                                     int expire)
The code first sets the Expires header to a date in the past. This indicates to the recipient that the page's content have already expired, as a hint that it's contents should not be cached. The no-cache value for the Pragma header is provided by version 1.0 of the HTTP protocol to further indicate that browsers and proxy servers should not cache a page. Version 1.1 of HTTP replaces this header with a more specific Cache-Control header, but recommends including the Pragma header as well for backward compatibility.

Parameters:
response - - http response
expire - - millisecond before content should expire

getWebappUri

public static java.lang.String getWebappUri(javax.servlet.http.HttpServletRequest request)
get WebappUri.

Parameters:
request - HttpServletRequest
Returns:
String

getSecureWebappUri

public static java.lang.String getSecureWebappUri(javax.servlet.http.HttpServletRequest request)
get Secure WebappUri.

Parameters:
request - HttpServletRequest
Returns:
String

getServerDocRoot

public static java.lang.String getServerDocRoot(javax.servlet.http.HttpServletRequest request)
get Server Document Root

Parameters:
request - HttpServletRequest
Returns:
String

getSecureServerDocRoot

public static java.lang.String getSecureServerDocRoot(javax.servlet.http.HttpServletRequest request)
get Secure Server Document Root

Parameters:
request - HttpServletRequest
Returns:
String

determinePathToRoot

public static java.lang.String determinePathToRoot(javax.servlet.http.HttpServletRequest request,
                                                   java.lang.String uri)
Determines the relative path to the root (e.g. ../../..) for the given request. Does not end with '/'!

Parameters:
request -
uri - the uri to use or request.getRequestURL() if null
Returns:
relative path

getURLContent

public java.lang.String getURLContent(java.lang.String urlPath)
get Remote Content

Parameters:
urlPath - - path to resource
Returns:
content of resource

getURLContent

public static java.lang.String getURLContent(java.net.URL url)
get Remote Content

Parameters:
url - - url to resource
Returns:
content of resource

getURLContentPost

public static java.lang.String getURLContentPost(java.net.URL url,
                                                 java.lang.String body)
Post a string to an URL and get the reply as a string. Returns an empty string if things didn't work out.

Parameters:
url - - url to resource
body - - content to post
Returns:
copntent of resource

getErrorInfo

public static java.lang.String getErrorInfo(javax.servlet.http.HttpServletRequest request,
                                            java.lang.Throwable exception,
                                            long ticket,
                                            java.lang.String version)

getAllRequestInfo

public static java.lang.String getAllRequestInfo(javax.servlet.http.HttpServletRequest request)

getRequestInfo

public static java.lang.String getRequestInfo(javax.servlet.http.HttpServletRequest request)

getCookieInfo

public static java.lang.String getCookieInfo(javax.servlet.http.HttpServletRequest request)

getSessionInfo

public static java.lang.String getSessionInfo(javax.servlet.http.HttpServletRequest request)


Copyright © 2003-2006 mmapps. All Rights Reserved.