com.bristle.javalib.net.http
Class HttpUtil

java.lang.Object
  extended by com.bristle.javalib.net.http.HttpUtil

public class HttpUtil
extends Object

This class contains utility routines for interacting with the HTTP protocol.

Usage:
   - The typical scenario for using this class is:
     - To get the user's credentials, prompting if necessary:
               HttpUtil.Credentials credentials = HttpUtil.getCredentials
                               (request, 
                                response, 
                                "",
                                !HttpUtil.blnREJECT_CURRENT_CREDENTIALS,
                                HttpUtil.blnASK_CLIENT_IF_NECESSARY);
     - To reject any credentials the user may previously have specified,
       forcing a new prompt:
               HttpUtil.Credentials credentials = HttpUtil.getCredentials
                               (request, 
                                response, 
                                "", 
                                HttpUtil.blnREJECT_CURRENT_CREDENTIALS,
                                HttpUtil.blnASK_CLIENT_IF_NECESSARY);
     - To get any credentials the user may previously have specified,
       without permitting a new prompt:
               HttpUtil.Credentials credentials = HttpUtil.getCredentials
                               (request, 
                                null,
                                null,
                                !HttpUtil.blnREJECT_CURRENT_CREDENTIALS,
                                !HttpUtil.blnASK_CLIENT_IF_NECESSARY);
     - To get only the username, without permitting a new prompt:
               String strUsername = HttpUtil.getUsername(request);
Assumptions:
Effects:
       - Interacts with the HTTP client via the HTTP protocol.  If the HTTP
         client is a Web Browser, getCredentials may cause it to prompt its 
         interactive user for credentials.
Anticipated Changes:
Notes:
Implementation Notes:
Portability Issues:
Revision History:
   $Log$


Nested Class Summary
static class HttpUtil.Credentials
          Nested class used as argument of getCredentials, so that it can allocate and return multiple Strings.
static class HttpUtil.Tester
          Each class contains a Tester inner class with a main() for easier unit testing.
 
Field Summary
static boolean blnASK_CLIENT_IF_NECESSARY
          Constant for use as parameter to getCredentials().
static boolean blnREJECT_CURRENT_CREDENTIALS
          Constant for use as parameter to getCredentials().
static boolean blnUSE_PATH_TO_SERVLET_FOLDER
          Constant for use as parameter to getConfigFileName().
static boolean blnUSE_SERVER_NAME
          Constant for use as parameter to getConfigFileName().
private static Map st_mapAbbrevs
           
static String strCONTENT_TYPE_HTML
          HTML content-type.
static String strCONTENT_TYPE_XML
          XML content-type.
static String strUSER_AGENT_UNKNOWN
          Constant included in the value returned by getHttpUserAgentAbbrev() when the specified user agent string and/or OS are unknown.
 
Constructor Summary
HttpUtil()
           
 
Method Summary
static String getConfigFileName(HttpServletRequest request, String strPrefix, String strSuffix)
          Get the fully qualified filename of a config file.
static String getConfigFileName(HttpServletRequest request, String strPrefix, String strSuffix, boolean blnUsePathToServletFolder, boolean blnUseServerName)
          Get the fully qualified filename of a config file.
static GetOpt getCookies(HttpServletRequest request)
          Returns a GetOpt object that can be used to get the values of the HTTP cookies of the specified HttpServletRequest object.
static HttpUtil.Credentials getCredentials(HttpServletRequest request, HttpServletResponse response, String strRealm, boolean blnRejectCurrentCredentials, boolean blnAskClientIfNecessary)
          Get the credentials of the current user from the HTTP client via the HTTP protocol.
static String getFormattedStringOfParameters(HttpServletRequest request)
          Return a formatted multi-line string containing all parameter names and values of the specified HttpServletRequest.
static String getFullRequestURI(HttpServletRequest request)
          Return the full URI string, including URI parameters.
static String getFullRequestURL(HttpServletRequest request)
          Return the full URL string, including URL parameters.
static GetOpt getHeaders(HttpServletRequest request)
          Returns a GetOpt object that can be used to get the values of the HTTP headers of the specified HttpServletRequest object.
static String getHttpUserAgentAbbrev(String strHttpUserAgent)
          Return a short human-readable abbreviation for the Web browser that is identified by the specified user agent string, which should be the full string value of the HTTP "user-agent" header from a common Web browser.
static Document getInfoAvailableToServlet(HttpServlet servlet, HttpServletRequest request)
          Get an XML DOM document containing all information available to a servlet.
static int getParam_int(HttpServletRequest request, String strName)
          Returns the int value of the parameter with the specified name, getting it from the specified HttpServletRequest object.
static int getParam_int(HttpServletRequest request, String strName, int intDefault)
          Returns the int value of the parameter with the specified name, getting it from the specified HttpServletRequest object.
static String getParam(HttpServletRequest request, String strName)
          Returns the value of the parameter with the specified name, getting it from the specified HttpServletRequest object, and mapping empty values to null.
static Integer getParamInteger(HttpServletRequest request, String strName)
          Returns the Integer value of the parameter with the specified name, getting it from the specified HttpServletRequest object, and mapping non-integer values to null.
static boolean getParamPresent(HttpServletRequest request, String strName)
          Returns true if the parameter with the specified name is present in the HttpServletRequest object; false otherwise.
static GetOpt getParams(HttpServletRequest request)
          Returns a GetOpt object that can be used to get the values of the HTTP parameters of the specified HttpServletRequest object.
static String getParamString(HttpServletRequest request, String strName, String strDefault)
          Returns the value of the parameter with the specified name, getting it from the specified HttpServletRequest object, and mapping empty values ("") and missing parameters (null) to the specified default.
static Object getServletAttribute(HttpServletRequest request, String strName)
          Get the value of the specified attribute from the ServletContext (application context) of the servlet associated with the specified HttpServletRequest.
static ServletContext getServletContext(HttpServletRequest request)
          Get the ServletContext of the specified request.
static String getServletDirectory(GenericServlet servlet)
          Get the full path of the directory where the specified servlet resides.
static String getServletDirectory(HttpServletRequest request)
          Get the full path of the directory where the servlet associated with the specified request resides.
static String getServletDirectory(ServletContext context)
          Get the full path of the directory associated with the specified ServletContext.
static int getSessionAttribute_int(HttpServletRequest request, String strName, int intDefault)
          Get the int value of the specified attribute from the Session associated with the specified HttpServletRequest.
static Object getSessionAttribute(HttpServletRequest request, String strName)
          Get the value of the specified attribute from the Session associated with the specified HttpServletRequest.
static String getUsername(HttpServletRequest request)
          Get the uppercased username of the current user from the HTTP headers of the specified HTTP request.
static Reader openHttpReader(String strURL, HttpUtil.Credentials credentials)
          Open a Reader to the specified URL, using the specified HTTP credentials.
static Reader openURLReader(String strURL)
          Open a Reader to the specified URL.
static void setResponseDownloadFilename(HttpServletResponse response, String strFilename)
          Set the response header to indentify the response content as a file download, specifying a default name for the HTTP client to use when saving the file.
static void setResponseNoCache(HttpServletResponse response)
          Set the response header to prevent caching of the page by the browser.
static void setServletAttribute(HttpServletRequest request, String strName, Object obj)
          Set the value of the specified attribute in the ServletContext (application context) of the servlet associated with the specified HttpServletRequest.
static void setSessionAttribute(HttpServletRequest request, String strName, Object obj)
          Set the value of the specified attribute in the Session associated with the specified HttpServletRequest.
static void writeFriendlyErrorMessage(HttpServletResponse response, String strMessage, Throwable throwable)
          Write a friendly error message to the HTTP client.
static void writeInfoAvailableToServlet(HttpServlet servlet, HttpServletRequest request, HttpServletResponse response)
          Write as an XML stream to the HTTP client all information available to a servlet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

st_mapAbbrevs

private static Map st_mapAbbrevs

strCONTENT_TYPE_HTML

public static final String strCONTENT_TYPE_HTML
HTML content-type.

See Also:
Constant Field Values

strCONTENT_TYPE_XML

public static final String strCONTENT_TYPE_XML
XML content-type.

See Also:
Constant Field Values

strUSER_AGENT_UNKNOWN

public static final String strUSER_AGENT_UNKNOWN
Constant included in the value returned by getHttpUserAgentAbbrev() when the specified user agent string and/or OS are unknown.

See Also:
Constant Field Values

blnREJECT_CURRENT_CREDENTIALS

public static final boolean blnREJECT_CURRENT_CREDENTIALS
Constant for use as parameter to getCredentials().

See Also:
Constant Field Values

blnASK_CLIENT_IF_NECESSARY

public static final boolean blnASK_CLIENT_IF_NECESSARY
Constant for use as parameter to getCredentials().

See Also:
Constant Field Values

blnUSE_PATH_TO_SERVLET_FOLDER

public static final boolean blnUSE_PATH_TO_SERVLET_FOLDER
Constant for use as parameter to getConfigFileName().

See Also:
Constant Field Values

blnUSE_SERVER_NAME

public static final boolean blnUSE_SERVER_NAME
Constant for use as parameter to getConfigFileName().

See Also:
Constant Field Values
Constructor Detail

HttpUtil

public HttpUtil()
Method Detail

getCredentials

public static HttpUtil.Credentials getCredentials(HttpServletRequest request,
                                                  HttpServletResponse response,
                                                  String strRealm,
                                                  boolean blnRejectCurrentCredentials,
                                                  boolean blnAskClientIfNecessary)
                                           throws IOException
Get the credentials of the current user from the HTTP client via the HTTP protocol. If the HTTP client did not already send them as an HTTP header or if blnRejectCurrentCredentials is true, return null to the calling routine. Before returning null, if blnAskClientIfNecessary is true, send a response to the HTTP client asking it to re-issue the HTTP request with the credentials. If the HTTP client is a Web Browser, this may cause it to prompt its user for credentials before re-issuing the request.

Parameters:
request - The HttpServletRequest object used to get the HTTP headers from the HTTP client.
response - The HttpServletResponse object used to tell the HTTP client to re-issue the HTTP request. Can be null if blnAskClientIfNecessary is false.
strRealm - String to pass to the HTTP client as the "realm". If the client is a Web Browser, it may show this string to its user when prompting for credentials. Can be null if blnAskClientIfNecessary is false.
blnRejectCurrentCredentials - Boolean specifying whether to reject any credentials already in the HTTP headers.
blnAskClientIfNecessary - Boolean specifying whether to allow any interaction with the HTTP client that may cause it to prompt its user for new credentials.
Returns:
Credentials object containing the credentials, or null if no credentials are available yet.
Throws:
IOException - When an I/O error occurs trying to tell the HTTP client to re-issue the HTTP request with credentials, or when an error occurs trying to decode the credentials sent by the HTTP client.

getUsername

public static String getUsername(HttpServletRequest request)
Get the uppercased username of the current user from the HTTP headers of the specified HTTP request. If the username is not already contained in the HTTP headers, return "". Do not interact further with the HTTP client, attempting to determine the username.

Parameters:
request - The HttpServletRequest object used to get the HTTP headers from the HTTP client.
Returns:
String containing the username, or "".
See Also:
getCredentials(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String, boolean, boolean)

getParams

public static GetOpt getParams(HttpServletRequest request)
Returns a GetOpt object that can be used to get the values of the HTTP parameters of the specified HttpServletRequest object.

Parameters:
request - The HttpServletRequest to get the parameters from.
Returns:
The GetOpt object.

getHeaders

public static GetOpt getHeaders(HttpServletRequest request)
Returns a GetOpt object that can be used to get the values of the HTTP headers of the specified HttpServletRequest object.

Parameters:
request - The HttpServletRequest to get the headers from.
Returns:
The GetOpt object.

getCookies

public static GetOpt getCookies(HttpServletRequest request)
Returns a GetOpt object that can be used to get the values of the HTTP cookies of the specified HttpServletRequest object.

Parameters:
request - The HttpServletRequest to get the cookies from.
Returns:
The GetOpt object.

getParamPresent

public static boolean getParamPresent(HttpServletRequest request,
                                      String strName)
Returns true if the parameter with the specified name is present in the HttpServletRequest object; false otherwise.

Parameters:
request - The HttpServletRequest object to get the value from.
strName - Name of the parameter.
Returns:
true if present; false otherwise.

getParam

public static String getParam(HttpServletRequest request,
                              String strName)
Returns the value of the parameter with the specified name, getting it from the specified HttpServletRequest object, and mapping empty values to null.

Parameters:
request - The HttpServletRequest object to get the value from.
strName - Name of the parameter.
Returns:
Null or the parameter value.

getParamString

public static String getParamString(HttpServletRequest request,
                                    String strName,
                                    String strDefault)
Returns the value of the parameter with the specified name, getting it from the specified HttpServletRequest object, and mapping empty values ("") and missing parameters (null) to the specified default.

Parameters:
request - The HttpServletRequest object to get the value from.
strName - Name of the parameter.
strDefault - Default value to use if no parameter value exists.
Returns:
Parameter value.

getParamInteger

public static Integer getParamInteger(HttpServletRequest request,
                                      String strName)
Returns the Integer value of the parameter with the specified name, getting it from the specified HttpServletRequest object, and mapping non-integer values to null.

Parameters:
request - The HttpServletRequest object to get the value from.
strName - Name of the parameter.
Returns:
Null or the parameter value.

getParam_int

public static int getParam_int(HttpServletRequest request,
                               String strName)
Returns the int value of the parameter with the specified name, getting it from the specified HttpServletRequest object. If the value cannot be interpreted as an int, an exception is thrown.

Parameters:
request - The HttpServletRequest object to get the value from.
strName - Name of the parameter.
Returns:
Parameter value.
Throws:
NullPointerException - When the specified value cannot be interpreted as an int.

getParam_int

public static int getParam_int(HttpServletRequest request,
                               String strName,
                               int intDefault)
Returns the int value of the parameter with the specified name, getting it from the specified HttpServletRequest object. If the value cannot be interpreted as an int, the specified default value is returned.

Parameters:
request - The HttpServletRequest object to get the value from.
strName - Name of the parameter.
intDefault - Default value to use if no valid parameter value exists.
Returns:
Parameter value.

openURLReader

public static Reader openURLReader(String strURL)
                            throws IOException
Open a Reader to the specified URL.

Parameters:
strURL - URL to connect to.
Returns:
Reader connected to the URL.
Throws:
IOException - When an I/O error occurs reading from the URL.

openHttpReader

public static Reader openHttpReader(String strURL,
                                    HttpUtil.Credentials credentials)
                             throws IOException
Open a Reader to the specified URL, using the specified HTTP credentials.

Parameters:
strURL - URL to connect to.
credentials - Credentials to use in connecting.
Returns:
Reader connected to the URL.
Throws:
IOException - When an I/O error occurs reading from the URL.

getFullRequestURL

public static String getFullRequestURL(HttpServletRequest request)
Return the full URL string, including URL parameters. This is like HttpServletRequest.getRequestURL(), but also includes the URL parameters. For example: http://bristle.com:1234/servletname?p1=abc&p2=def

Parameters:
request - The HttpServletRequest object of the servlet.

getFullRequestURI

public static String getFullRequestURI(HttpServletRequest request)
Return the full URI string, including URI parameters. This is like HttpServletRequest.getRequestURI(), but also includes the URI parameters. For example: /servletname?p1=abc&p2=def

Parameters:
request - The HttpServletRequest object of the servlet.

getServletContext

public static ServletContext getServletContext(HttpServletRequest request)
Get the ServletContext of the specified request.

Parameters:
request - The HttpServletRequest object.
Returns:
The ServletContext object.

getServletDirectory

public static String getServletDirectory(ServletContext context)
Get the full path of the directory associated with the specified ServletContext.

Parameters:
context - The ServletContext
Returns:
Full path of the directory, ending in a path separator (typically "/") for the native file system, as returned by java.io.File.separator.

getServletDirectory

public static String getServletDirectory(GenericServlet servlet)
Get the full path of the directory where the specified servlet resides.

Parameters:
servlet - The HttpServlet object.
Returns:
Full path of the directory, ending in a path separator (typically "/") for the native file system, as returned by java.io.File.separator.

getServletDirectory

public static String getServletDirectory(HttpServletRequest request)
Get the full path of the directory where the servlet associated with the specified request resides.

Parameters:
request - The HttpServletRequest object.
Returns:
Full path of the directory, ending in a path separator (typically "/") for the native file system, as returned by java.io.File.separator.

getSessionAttribute

public static Object getSessionAttribute(HttpServletRequest request,
                                         String strName)
Get the value of the specified attribute from the Session associated with the specified HttpServletRequest.

Parameters:
request - The HttpServletRequest object.
strName - The attribute name.
Returns:
The requested value.

getSessionAttribute_int

public static int getSessionAttribute_int(HttpServletRequest request,
                                          String strName,
                                          int intDefault)
Get the int value of the specified attribute from the Session associated with the specified HttpServletRequest. If any error occurs (no Session, no such attribute, attribute value not an int, etc.), return the specified default value.

Parameters:
request - The HttpServletRequest object.
strName - The attribute name.
intDefault - Default value to use if an error occurs.
Returns:
The requested value.

setSessionAttribute

public static void setSessionAttribute(HttpServletRequest request,
                                       String strName,
                                       Object obj)
Set the value of the specified attribute in the Session associated with the specified HttpServletRequest.

Parameters:
request - The HttpServletRequest object.
strName - The attribute name.

getServletAttribute

public static Object getServletAttribute(HttpServletRequest request,
                                         String strName)
Get the value of the specified attribute from the ServletContext (application context) of the servlet associated with the specified HttpServletRequest.

Parameters:
request - The HttpServletRequest object.
strName - The attribute name.
Returns:
The requested value.

setServletAttribute

public static void setServletAttribute(HttpServletRequest request,
                                       String strName,
                                       Object obj)
Set the value of the specified attribute in the ServletContext (application context) of the servlet associated with the specified HttpServletRequest.

Parameters:
request - The HttpServletRequest object.
strName - The attribute name.

getInfoAvailableToServlet

public static Document getInfoAvailableToServlet(HttpServlet servlet,
                                                 HttpServletRequest request)
Get an XML DOM document containing all information available to a servlet. Format of XML is: <InfoAvailableToServlet> //?? Update to match code -- new additions. <RemoteUser>xxx</RemoteUser> <RemoteHost>xxx</RemoteHost> <RemoteAddr>xxx</RemoteAddr> <RemotePort>xxx</RemotePort> <AuthType>xxx</AuthType> <HttpUserAgent>xxx</HttpUserAgent> <HttpReferer>xxx</HttpReferer> <Method>xxx</Method> <FullRequestURL>xxx</FullRequestURL> <RequestURL>xxx</RequestURL> <Protocol>xxx</Protocol> <isSecure>xxx</isSecure> <Scheme>xxx</Scheme> <ServerName>xxx</ServerName> <ServerPort>xxx</ServerPort> <FullRequestURI>xxx</FullRequestURI> <RequestURI>xxx</RequestURI> <ContextPath>xxx</ContextPath> <ServletPath>xxx</ServletPath> <PathInfo>xxx</PathInfo> <PathTranslated>xxx</PathTranslated> <QueryString>xxx</QueryString> <CharacterEncoding>xxx</CharacterEncoding> <ContentType>xxx</ContentType> <ContentLength>xxx</ContentLength> <LocalAddr>xxx</LocalAddr> <LocalName>xxx</LocalName> <LocalPort>xxx</LocalPort> <HttpAccept>xxx</HttpAccept> <RequestHeaders> <RequestHeader> <HeaderName>xxx</HeaderName> <HeaderValue>xxx</HeaderValue> </RequestHeader> ... </RequestHeaders> <RequestParams> <RequestParam> <ParamName>xxx</ParamName> <ParamValue>xxx</ParamValue> </RequestParam> ... </RequestParams> <RequestAttributes> <RequestAttribute> <AttributeName>xxx</AttributeName> <AttributeValue>xxx</AttributeValue> </RequestAttribute> ... </RequestAttributes> <RequestCookies> <RequestCookie> <CookieName>xxx</CookieName> <CookieValue>xxx</CookieValue> <CookieComment>xxx</CookieComment> <CookieDomain>xxx</CookieDomain> <CookieMaxAge>xxx</CookieMaxAge> <CookiePath>xxx</CookiePath> <CookieSecure>xxx</CookieSecure> <CookieVersion>xxx</CookieVersion> </RequestCookie> ... </RequestCookies> <SessionId>xxx</SessionId> <isNew>xxx</isNew> <SessionCreationTime>xxx</SessionCreationTime> <SessionLastAccessedTime>xxx</SessionLastAccessedTime> <SessionMaxInactiveInterval>xxx</SessionMaxInactiveInterval> <SessionAttributes> <SessionAttribute> <AttributeName>xxx</AttributeName> <AttributeValue>xxx</AttributeValue> </SessionAttribute> ... </SessionAttributes> <ServerInfo>xxx</ServerInfo> <DocumentRoot>xxx</DocumentRoot> <MajorVersion>xxx</MajorVersion> <MinorVersion>xxx</MinorVersion> <ServerAttributes> <ServerAttribute> <AttributeName>xxx</AttributeName> <AttributeValue>xxx</AttributeValue> </ServerAttribute> ... </ServerAttributes> <SystemProps> <SystemProp> <PropName>xxx</PropName> <PropValue>xxx</PropValue> </SystemProp> ... </SystemProps> <ServletName>xxx</ServletName> <ClassName>xxx</ClassName> <PackageName>xxx</PackageName> <InitParams> <InitParam> <ParamName>xxx</ParamName> <ParamValue>xxx</ParamValue> </InitParam> ... </InitParams> <ConfigURL>xxx</ConfigURL> </InfoAvailableToServlet>

Parameters:
servlet - The HttpServlet object defining the servlet.
request - The HttpServletRequest object of the servlet.
Returns:
The XML DOM Document

writeInfoAvailableToServlet

public static void writeInfoAvailableToServlet(HttpServlet servlet,
                                               HttpServletRequest request,
                                               HttpServletResponse response)
                                        throws IOException
Write as an XML stream to the HTTP client all information available to a servlet. Format of XML is as shown in getInfoAvailableToServlet.

Parameters:
servlet - The HttpServlet object defining the servlet.
request - The HttpServletRequest object of the servlet.
response - The HttpServletResponse object of the servlet.
Throws:
IOException - When an I/O error occurs during interaction with the servlet, request, or response.

writeFriendlyErrorMessage

public static void writeFriendlyErrorMessage(HttpServletResponse response,
                                             String strMessage,
                                             Throwable throwable)
Write a friendly error message to the HTTP client.

Parameters:
response - The HttpServletResponse object of the servlet.
strMessage - A String to put in front of the error message.
throwable - The Throwable containing the error message.

setResponseNoCache

public static void setResponseNoCache(HttpServletResponse response)
Set the response header to prevent caching of the page by the browser.

Parameters:
response - The HttpServletResponse object.

setResponseDownloadFilename

public static void setResponseDownloadFilename(HttpServletResponse response,
                                               String strFilename)
Set the response header to indentify the response content as a file download, specifying a default name for the HTTP client to use when saving the file. When the HTTP client is a browser, it typically prompts the user with a "File Download" dialog, asking whether to open the file or save it to disk. If the user chooses to save it to disk, the browser typically pops up a "Save As" dialog, allowing the user to choose a location. The filename specified here is the default filename used within the user specified directory. If the user chooses to open the file, the browser typically invokes the application associated with the filename extension. For example, a ".csv" extension might cause the browser to invoke Microsoft Excel.

Parameters:
response - The HttpServletResponse object.
strFilename - The name of the file.

getHttpUserAgentAbbrev

public static String getHttpUserAgentAbbrev(String strHttpUserAgent)
Return a short human-readable abbreviation for the Web browser that is identified by the specified user agent string, which should be the full string value of the HTTP "user-agent" header from a common Web browser. This is useful for logging, summarizing, etc, but does not carry as much info as the full header string. Header strings that differ in terms of exact version number, OS, modes, etc., may generate the same abbreviation.

Parameters:
strHttpUserAgent - The full string value of the "user-agent" header from a common Web browser.
Returns:
Abbreviation for the user agent string. If the browser and/or OS is unknown, the value of strUSER_AGENT_UNKNOWN may occur as portions of the abbreviation. Examples: FF2.x-Lin, SFx-Mac, UNK-Win, UNK-UNK, etc.

getFormattedStringOfParameters

public static String getFormattedStringOfParameters(HttpServletRequest request)
Return a formatted multi-line string containing all parameter names and values of the specified HttpServletRequest.

Parameters:
request - The HttpServletRequest object.
Returns:
String of parameter names and values. Example: action: login selectedOptions: 1 2 7 username: fred

getConfigFileName

public static String getConfigFileName(HttpServletRequest request,
                                       String strPrefix,
                                       String strSuffix,
                                       boolean blnUsePathToServletFolder,
                                       boolean blnUseServerName)
Get the fully qualified filename of a config file. The filename is built as: path_to_servlet_folder/prefixservernamesuffix from 4 parts, all of which are optional: Examples:

Parameters:
request - HttpServletRequest object.
strPrefix - The prefix to use, or null or empty string.
strSuffix - The suffix to use, or null or empty string.
blnUsePathToServletFolder - If false, the path to the servlet folder and its trailing path separator are omitted.
blnUseServerName - If false, servername is omitted, so the prefix is immediately followed by the suffix.
Returns:
Fully qualified config file name.

getConfigFileName

public static String getConfigFileName(HttpServletRequest request,
                                       String strPrefix,
                                       String strSuffix)
Get the fully qualified filename of a config file. The filename is built as: path_to_servlet_folder/prefixservernamesuffix Calls getConfigFileName(HttpServletRequest, String, String, boolean, boolean) specifying true for the 2 boolean parameters.

Parameters:
request - HttpServletRequest object.
strPrefix - The prefix to use, or null or empty string.
strSuffix - The suffix to use, or null or empty string.
Returns:
Fully qualified config file name.