Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.util
Class ServletUtils

java.lang.Object
  extended by com.jivesoftware.util.ServletUtils

public class ServletUtils
extends java.lang.Object

Utility class for working with servlet container objects, such as HttpServletRequest and HttpServletResponse.


Method Summary
static java.lang.String getEtag(byte[] bytes)
          Generates an Etag given a byte array.
static java.lang.String getEtag(long size)
          Generates an Etag given a file size.
static java.lang.String getServletPath(javax.servlet.http.HttpServletRequest request)
          Returns the servlet path of a request.
static boolean isModified(javax.servlet.http.HttpServletRequest request, byte[] bytes, long modified)
          Checks to see if the request script has been modified since the last time the given browser has requested the script based on the 'If-Modified-Since' and 'If-None-Match' headers.
static boolean isModified(javax.servlet.http.HttpServletRequest request, long fileSize, long modified)
          Checks to see if the request script has been modified since the last time the given browser has requested the script based on the 'If-Modified-Since' and 'If-None-Match' headers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getServletPath

public static java.lang.String getServletPath(javax.servlet.http.HttpServletRequest request)
Returns the servlet path of a request. Some servlet containers return various strange, unhelpful values from HttpServletRequest.getServletPath(), so this function tries a few methods to get the same information.

Parameters:
request - the HttpServletRequest to get the path information from.
Returns:
the servlet path

isModified

public static boolean isModified(javax.servlet.http.HttpServletRequest request,
                                 byte[] bytes,
                                 long modified)
Checks to see if the request script has been modified since the last time the given browser has requested the script based on the 'If-Modified-Since' and 'If-None-Match' headers. This method will return true unless both headers are present and are equal to the values generated by getEtag(byte[]) and lastmodified (which is the server startup).

Parameters:
request - the request to get the headers from
bytes - the bytes to check for modifications
modified - the last time the script was modified
Returns:
true if neither of the headers are present, false if both of the headers are present and are exact matches to the values generated from the given feed.

isModified

public static boolean isModified(javax.servlet.http.HttpServletRequest request,
                                 long fileSize,
                                 long modified)
Checks to see if the request script has been modified since the last time the given browser has requested the script based on the 'If-Modified-Since' and 'If-None-Match' headers. This method will return true unless both headers are present and are equal to the values generated by getEtag(byte[]) and lastmodified (which is the server startup).

Parameters:
request - the request to get the headers from
fileSize - the fileSize to compute the etag with
modified - the last time the script was modified
Returns:
true if neither of the headers are present, false if both of the headers are present and are exact matches to the values generated from the given feed.

getEtag

public static java.lang.String getEtag(byte[] bytes)
Generates an Etag given a byte array. Currently the Etag is the string value of the length of the given byte array.

NOTE: The Etag value must be quoted.

For more information, visit the Etag specification.

Parameters:
bytes - the bytes value of a script to compute an Etag for
Returns:
an etag.

getEtag

public static java.lang.String getEtag(long size)
Generates an Etag given a file size. The generated etag includes the version # so resources are reloaded after every upgrade. If the application has not been initialized, the generated etag will not include the version # but instead will by prefixed by the string 'setup-'.

NOTE: The Etag value must be quoted.

For more information, visit the Etag specification.

Parameters:
size - the file size to compute an Etag for
Returns:
an etag.

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.