info.aduna.gee.publication.servlets.util
Class HttpServletUtil

java.lang.Object
  extended by info.aduna.gee.publication.servlets.util.HttpServletUtil

public class HttpServletUtil
extends Object


Constructor Summary
HttpServletUtil()
           
 
Method Summary
protected static HashMap _unpackMultipartFormData(javax.servlet.http.HttpServletRequest request)
          Unpack multipart/form-data
protected static HashMap _unpackQueryString(javax.servlet.http.HttpServletRequest request)
          Unpack queryString, comparable to how a form is unpacked.
protected static HashMap _unpackURLEncodedFormData(javax.servlet.http.HttpServletRequest request)
          Unpack x-www-form-urlencoded
static String checkFileExtension(String name)
          A work-around for IE under certain conditons: File names come in corrupted as e.g.: ferrari.jpgggggg, mydocument.docccccc But note: hangman.class The correct extension is important for automatic type recognition.
static String decompileQueryString(String query)
          Decompiles a query-string.
static void doEnd(javax.servlet.http.HttpServletRequest request, String name)
           
static String doStart(javax.servlet.http.HttpServletRequest request, String name)
          Do some bookkeeping at the start of each doGet() or doPost(): - set the name of the thread - determine the name of the host
protected static String findAttribute(String startPattern, String endPattern, byte[] sourceArray)
          Finds an attribute's value in a byte-array.
protected static int findIndexOf(byte[] toFind, byte[] source, int offset)
          Finds the first occurrence of 'toFind' in 'source', starting at offset 'offset'.
static String getFakeServerPath(String host)
          Don't use this method, unless there is no way to use getServerPath.
static String getParameter(javax.servlet.http.HttpServletRequest request, String parameter)
          Because IE's bug that substitutes §ion=...
static String getServerPath(javax.servlet.http.HttpServletRequest request)
           
static String getServiceName(javax.servlet.http.HttpServletRequest request, String defValue)
          Get the component immediately following the current servlet path.
static String gsub(String olds, String news, String text)
           
static boolean isEmpty(String string)
           
static boolean isFalse(String string)
           
static boolean isTrue(String string)
           
static void noCache(javax.servlet.http.HttpServletResponse response)
          Netscape will even Cache POST's! We have to prevend this manually and carefully.
static String normalizeHostname(String host)
          Create a normalized hostname from the hostname.
protected static byte[] trimReturns(byte[] source)
          Remove one \n or \r\n (and combination thereof) from the beginning and end of the specified byte array.
static HashMap unpackFormData(javax.servlet.http.HttpServletRequest request)
          Unpack any type of form data
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpServletUtil

public HttpServletUtil()
Method Detail

doStart

public static String doStart(javax.servlet.http.HttpServletRequest request,
                             String name)
Do some bookkeeping at the start of each doGet() or doPost(): - set the name of the thread - determine the name of the host

Parameters:
request - The request.
name - The name of the thread
Returns:
The name of the host the request is for.

doEnd

public static void doEnd(javax.servlet.http.HttpServletRequest request,
                         String name)

normalizeHostname

public static String normalizeHostname(String host)
Create a normalized hostname from the hostname. - Replace server aliases by the main name. - Replace all '.' with '_' - Replace all '-' with '_' - Convert to lower case. Is used e.g. because some databases have restrictions on the database name (which therefore can not be the hostname itself e.g. zpad1.zpad.com).


checkFileExtension

public static String checkFileExtension(String name)
A work-around for IE under certain conditons: File names come in corrupted as e.g.: ferrari.jpgggggg, mydocument.docccccc But note: hangman.class The correct extension is important for automatic type recognition.


decompileQueryString

public static String decompileQueryString(String query)
Decompiles a query-string. IE replaces "§ion=..." by "$ion=...", where $=\247. This method corrects this.


unpackFormData

public static HashMap unpackFormData(javax.servlet.http.HttpServletRequest request)
Unpack any type of form data


_unpackURLEncodedFormData

protected static HashMap _unpackURLEncodedFormData(javax.servlet.http.HttpServletRequest request)
Unpack x-www-form-urlencoded


_unpackMultipartFormData

protected static HashMap _unpackMultipartFormData(javax.servlet.http.HttpServletRequest request)
Unpack multipart/form-data


findIndexOf

protected static int findIndexOf(byte[] toFind,
                                 byte[] source,
                                 int offset)
Finds the first occurrence of 'toFind' in 'source', starting at offset 'offset'.


findAttribute

protected static String findAttribute(String startPattern,
                                      String endPattern,
                                      byte[] sourceArray)
Finds an attribute's value in a byte-array. The returned 'value' is defined as the bytes between 'startPattern' and 'endPattern'.


trimReturns

protected static byte[] trimReturns(byte[] source)
Remove one \n or \r\n (and combination thereof) from the beginning and end of the specified byte array.


isEmpty

public static boolean isEmpty(String string)
Returns:
true if the string is either null or equal to ""

isTrue

public static boolean isTrue(String string)
Returns:
true if the string is !isEmpty and equal to "true"

isFalse

public static boolean isFalse(String string)
Returns:
true if the string is !isEmpty and equal to "false"

gsub

public static String gsub(String olds,
                          String news,
                          String text)
See Also:
WLabel.gsub(java.lang.String, java.lang.String, java.lang.String)

getParameter

public static String getParameter(javax.servlet.http.HttpServletRequest request,
                                  String parameter)
Because IE's bug that substitutes §ion=... by %ion=..., request.getParameter doesn't work. This is a workaround for it. Furthermore: in JSDK2.0 it seems that request.getParameter() is buggy. It replaces a "+" by a " " (section=today+5 -> getParameter("section") == "today 5". ONLY if the queryString does not contain the Parameter requested, we fall back to request.getParameter().

Returns:
the value of the requested parameter or null

_unpackQueryString

protected static HashMap _unpackQueryString(javax.servlet.http.HttpServletRequest request)
Unpack queryString, comparable to how a form is unpacked.


noCache

public static void noCache(javax.servlet.http.HttpServletResponse response)
Netscape will even Cache POST's! We have to prevend this manually and carefully.


getServiceName

public static String getServiceName(javax.servlet.http.HttpServletRequest request,
                                    String defValue)
Get the component immediately following the current servlet path. Within the Spectacle server this is (in a lot of cases) the (sub)service.

Parameters:
request - the original request
defValue - the default result value, in case request doesn't indicate one

getServerPath

public static String getServerPath(javax.servlet.http.HttpServletRequest request)

getFakeServerPath

public static String getFakeServerPath(String host)
Don't use this method, unless there is no way to use getServerPath. The result should NEVER be used to actually connect to the server.



Copyright © 1997-2008 Aduna. All Rights Reserved.