to.etc.domui.util
Class ServerTools

java.lang.Object
  extended by to.etc.domui.util.ServerTools

public final class ServerTools
extends java.lang.Object

Author:
jal Created on Jan 31, 2005

Method Summary
static void addMime(java.lang.String ext, java.lang.String mime)
           
static java.io.File findConfigFileByName(javax.servlet.ServletContext ctx, java.lang.String basename)
          Tries to find the named config file.
static void generateExpiryHeader(javax.servlet.http.HttpServletResponse res, int exp)
           
static void generateNoCache(javax.servlet.http.HttpServletResponse response)
          Sends headers that are needed to prevent the browser or any proxy in between from caching the page's contents.
static java.lang.String getExtMimeType(java.lang.String ext)
          Returns the mime type of a file by searching the file extension in the MIME table.
static int getInt(javax.servlet.http.HttpServletRequest req, java.lang.String name)
           
static int getInt(javax.servlet.http.HttpServletRequest req, java.lang.String name, int dflt)
           
static long getLong(javax.servlet.http.HttpServletRequest req, java.lang.String name)
          Gets a 'long' parameter from the request.
static java.lang.String getMimeExtension(java.lang.String mimetype)
           
static java.util.Properties getMimeMap()
           
static java.lang.String getMimeString(java.lang.String mime)
          This gets called with a MIME type string.
static java.lang.String getMimeType(java.lang.String fn)
          Returns the mime type of a file by searching the file extension in the MIME table.
static java.lang.String getMyHostname()
           
static java.lang.String getUniqueString()
          Returns an unique string every time it gets called.
static void initMimeMap()
          Load all MIME types.
static void loadMimeMap(java.io.File fn)
          Load all MIME types.
static java.lang.String makeTimeString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

findConfigFileByName

public static java.io.File findConfigFileByName(javax.servlet.ServletContext ctx,
                                                java.lang.String basename)
                                         throws java.lang.Exception
Tries to find the named config file. It tries the local directory first, followed by the WEB-INF path and all classpath entries.

Parameters:
ctx -
basename -
Returns:
Throws:
java.lang.Exception

getMyHostname

public static java.lang.String getMyHostname()

getMimeString

public static java.lang.String getMimeString(java.lang.String mime)
This gets called with a MIME type string. It returns the same string BUT it merges all of the same strings into a single object. That is every string 'image/jpeg' passed thru this function will return a SINGLE string object of that contents. This reserves lots of storage space when many objects refer to a mime type.

Parameters:
mime -
Returns:

getExtMimeType

public static java.lang.String getExtMimeType(java.lang.String ext)
Returns the mime type of a file by searching the file extension in the MIME table. If this table has not been loaded it gets loaded.


getMimeType

public static java.lang.String getMimeType(java.lang.String fn)
Returns the mime type of a file by searching the file extension in the MIME table. If this table has not been loaded it gets loaded.


getMimeExtension

public static java.lang.String getMimeExtension(java.lang.String mimetype)

addMime

public static void addMime(java.lang.String ext,
                           java.lang.String mime)

initMimeMap

public static void initMimeMap()
Load all MIME types. First load the default ones,


loadMimeMap

public static void loadMimeMap(java.io.File fn)
                        throws java.lang.Exception
Load all MIME types. First load the default ones,

Throws:
java.lang.Exception

getMimeMap

public static java.util.Properties getMimeMap()

makeTimeString

public static final java.lang.String makeTimeString()

getUniqueString

public static java.lang.String getUniqueString()
Returns an unique string every time it gets called. The string contains a sequence number and a time part that should be unique. The string consists of digits and letters [base64].


generateExpiryHeader

public static void generateExpiryHeader(javax.servlet.http.HttpServletResponse res,
                                        int exp)

generateNoCache

public static void generateNoCache(javax.servlet.http.HttpServletResponse response)
Sends headers that are needed to prevent the browser or any proxy in between from caching the page's contents.

Parameters:
res -

getLong

public static long getLong(javax.servlet.http.HttpServletRequest req,
                           java.lang.String name)
                    throws javax.servlet.ServletException
Gets a 'long' parameter from the request. Throws an exception if the parameter is not available or not a valid long number.

Parameters:
req -
name -
Returns:
Throws:
javax.servlet.ServletException

getInt

public static int getInt(javax.servlet.http.HttpServletRequest req,
                         java.lang.String name)
                  throws javax.servlet.ServletException
Throws:
javax.servlet.ServletException

getInt

public static int getInt(javax.servlet.http.HttpServletRequest req,
                         java.lang.String name,
                         int dflt)
                  throws javax.servlet.ServletException
Throws:
javax.servlet.ServletException