com.ibm.commerce.server
Class ServletHelper

java.lang.Object
  |
  +--com.ibm.commerce.server.ServletHelper

public class ServletHelper
extends java.lang.Object

The ServletHelper class contains static methods used by the request servlet


Constructor Summary
ServletHelper()
           
 
Method Summary
static void arrayCopy(java.lang.String[] fromArray, java.lang.String[] toArray)
          Copies the content of one array to another string array
static java.lang.String buildHttpsRedirectUrl(java.lang.String inUrl, TypedProperty reqProperties, HttpServletResponse response)
          Deprecated. Replaced by buildHttpsRedirectUrl(String,TypedProperty,HttpServletResponse,String)
static java.lang.String buildHttpsRedirectUrl(java.lang.String inUrl, TypedProperty reqProperties, HttpServletResponse response, java.lang.String encoding)
          Builds the url for redirection.
static java.lang.String buildRedirectUrl(java.lang.String inUrl, TypedProperty reqProperties, HttpServletResponse response)
          Deprecated. Replaced by buildRedirectUrl(String,TypedProperty,HttpServletResponse,String)
static java.lang.String buildRedirectUrl(java.lang.String inUrl, TypedProperty reqProperties, HttpServletResponse response, boolean encrypt)
          Deprecated. Replaced by buildRedirectUrl(String,TypedProperty,HttpServletResponse,boolean,String)
static java.lang.String buildRedirectUrl(java.lang.String inUrl, TypedProperty reqProperties, HttpServletResponse response, boolean encrypt, java.lang.String encoding)
          Builds the url for redirection.
static java.lang.String buildRedirectUrl(java.lang.String inUrl, TypedProperty reqProperties, HttpServletResponse response, java.lang.String encoding)
          Builds the url for redirection.
static java.lang.String composeEncodedQueryString(TypedProperty prop)
          Composes a query string from the typedProperties.
static java.lang.String composeQueryString(TypedProperty prop)
          Composse a query string from the typedProperties.
static java.lang.String decodeURL(java.lang.String val, java.lang.String encoding)
          Decode an url string with a given encoding.
static java.lang.String encodeURL(java.lang.String val, java.lang.String encoding)
          Encode an url string with a given encoding.
static TypedProperty extractEncodedRequestParameters(java.lang.String queryString)
          Deprecated. Replaced by extractEncodedRequestParameters(String,String)
static TypedProperty extractEncodedRequestParameters(java.lang.String queryString, java.lang.String encoding)
          Extracts the request parameters from a query string where each parameter is encoded, and convert it to a TypedProperty object.
static TypedProperty extractMultipartParameters(HttpServletRequest req)
          Extracts multipart request parameters from a HttpServletRequest and build an TypedProperty object based on the parameters.
static TypedProperty extractRequestParameters(java.lang.String queryString)
          Extracts the request parameters from a query string and convert it to a TypedProperty object.
static java.util.Hashtable getNVPHash(HttpServletRequest request)
          Gets the name value pairs.
static java.util.Hashtable getNVPHashArray(HttpServletRequest request)
          Returns Hashtable of key-value pairs, where the values are arrays of Strings.
static java.lang.String getParameter(HttpServletRequest request, java.lang.String name)
          Returns a parameter as string from the HttpServletRequest.
static java.lang.String getSessionID(HttpServletRequest req)
          Gets the sessoin Id.
static java.lang.Integer getStoreIdFromQueryString(HttpServletRequest req, java.lang.Integer defaultStoreId)
          Gets the store id fromthe query string.
static java.util.Vector getURLParameters(HttpServletRequest request)
          Gets the sessoin Id.
static java.lang.Integer getUserRefNum(HttpServletRequest req)
          Gets the user reference number.
static void markTransactionToRollback()
          Marks the current transaction for roll back.
static TypedProperty mergeRedirectUrlProperties(TypedProperty oldProp, TypedProperty urlProp)
          Merges the redirect URL parameter with other properties .
static java.lang.String protectQueryString(java.lang.String queryString)
          Parses a query string for protected parameters and replaces all protected paramaeter values with "*******"
static void rollbackTransaction()
          Rolls back the current transaction.
static java.lang.String servletRequestToString(javax.servlet.http.HttpServletRequest request)
          Extracts many useful information for debugging purposes from a HttpServletRequest.
static java.lang.String servletRequestToStringDebug(javax.servlet.http.HttpServletRequest request)
          Extracts all information useful for debugging purposes from a HttpServletRequest.
static void setEncoding(HttpServletRequest req, java.lang.Integer sessionLangId, java.lang.Integer storeId, java.lang.String defaultEncoding)
          Sets the encoding to be used to extract the input parameters.
static java.lang.String setEncoding(HttpServletRequest req, java.lang.String defaultEncoding)
          Set the encoding for used for retreiving request parameters.
static java.lang.String[] stringToArray(java.lang.String value)
          Converts a string with values seperated by commas to an array of strings.
static java.lang.Integer[] stringToIntegerArray(java.lang.String[] sarray)
          Converts an array of Strings to an array of Integers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletHelper

public ServletHelper()
Method Detail

arrayCopy

public static void arrayCopy(java.lang.String[] fromArray,
                             java.lang.String[] toArray)
Copies the content of one array to another string array
Parameters:
fromArray - original array
toArray - new array

buildHttpsRedirectUrl

public static java.lang.String buildHttpsRedirectUrl(java.lang.String inUrl,
                                                     TypedProperty reqProperties,
                                                     HttpServletResponse response)
                                              throws ECApplicationException
Deprecated. Replaced by buildHttpsRedirectUrl(String,TypedProperty,HttpServletResponse,String)
Builds the url for redirection. All url parameters will be encrypted.
Parameters:
inUrl - url
reqProperties - request properties
Returns:
the redirect url
Throws:
ECApplicationException -

buildHttpsRedirectUrl

public static java.lang.String buildHttpsRedirectUrl(java.lang.String inUrl,
                                                     TypedProperty reqProperties,
                                                     HttpServletResponse response,
                                                     java.lang.String encoding)
                                              throws ECApplicationException
Builds the url for redirection. All url parameters will be encrypted.
Parameters:
inUrl - url
reqProperties - request properties
encoding - character encoding
Returns:
the redirect url
Throws:
ECApplicationException

buildRedirectUrl

public static java.lang.String buildRedirectUrl(java.lang.String inUrl,
                                                TypedProperty reqProperties,
                                                HttpServletResponse response)
                                         throws ECApplicationException
Deprecated. Replaced by buildRedirectUrl(String,TypedProperty,HttpServletResponse,String)
Builds the url for redirection. All url parameters will be encrypted.
Parameters:
inUrl - url
reqProperties - request property
response - http servlet response
Returns:
the redirect url
Throws:
ECApplicationException -

buildRedirectUrl

public static java.lang.String buildRedirectUrl(java.lang.String inUrl,
                                                TypedProperty reqProperties,
                                                HttpServletResponse response,
                                                java.lang.String encoding)
                                         throws ECApplicationException
Builds the url for redirection. All url parameters will be encrypted.
Parameters:
inUrl - url
reqProperties - request property
response - http servlet response
encoding - character encoding
Returns:
the redirect url
Throws:
ECApplicationException

buildRedirectUrl

public static java.lang.String buildRedirectUrl(java.lang.String inUrl,
                                                TypedProperty reqProperties,
                                                HttpServletResponse response,
                                                boolean encrypt)
                                         throws ECApplicationException
Deprecated. Replaced by buildRedirectUrl(String,TypedProperty,HttpServletResponse,boolean,String)
Builds the url for redirection.
Parameters:
inUrl - url
reqProperties - request property
response - http servlet response
encrypt - true if the url parameters will be encrypted
Returns:
the redirect url
Throws:
ECApplicationException -

buildRedirectUrl

public static java.lang.String buildRedirectUrl(java.lang.String inUrl,
                                                TypedProperty reqProperties,
                                                HttpServletResponse response,
                                                boolean encrypt,
                                                java.lang.String encoding)
                                         throws ECApplicationException
Builds the url for redirection.
Parameters:
inUrl - url
reqProperties - request property
response - http servlet response
encrypt - true if the url parameters will be encrypted
encoding - character encoding
Returns:
the redirect url
Throws:
ECApplicationException

composeQueryString

public static java.lang.String composeQueryString(TypedProperty prop)
Composse a query string from the typedProperties.
Parameters:
prop - type properties
Returns:
the query string

extractEncodedRequestParameters

public static TypedProperty extractEncodedRequestParameters(java.lang.String queryString)
                                                     throws ECApplicationException
Deprecated. Replaced by extractEncodedRequestParameters(String,String)
Extracts the request parameters from a query string where each parameter is encoded, and convert it to a TypedProperty object.
Parameters:
queryString - query string
Returns:
type properties
Throws:
ECApplicationException -

extractEncodedRequestParameters

public static TypedProperty extractEncodedRequestParameters(java.lang.String queryString,
                                                            java.lang.String encoding)
                                                     throws ECApplicationException
Extracts the request parameters from a query string where each parameter is encoded, and convert it to a TypedProperty object.
Parameters:
queryString - query string
encoding - character encoding
Returns:
type properties
Throws:
ECApplicationException

extractRequestParameters

public static TypedProperty extractRequestParameters(java.lang.String queryString)
                                              throws ECApplicationException
Extracts the request parameters from a query string and convert it to a TypedProperty object. We assume that each parameter is not encoded
Parameters:
queryString - query string
Returns:
typed property
Throws:
ECApplicationException

extractMultipartParameters

public static TypedProperty extractMultipartParameters(HttpServletRequest req)
                                                throws ECApplicationException
Extracts multipart request parameters from a HttpServletRequest and build an TypedProperty object based on the parameters.
Parameters:
req - http servlet request
Returns:
typed property
Throws:
ECApplicationException

getNVPHash

public static java.util.Hashtable getNVPHash(HttpServletRequest request)
Gets the name value pairs.
Parameters:
request - http servlet request
Returns:
hashtable of the name value pairs.

getNVPHashArray

public static java.util.Hashtable getNVPHashArray(HttpServletRequest request)
Returns Hashtable of key-value pairs, where the values are arrays of Strings. (Keys that appear once in the query string have, in the hashtable, a string array of length one as their value. Keys that appear twice have a string array of length two, etc.)
Parameters:
request - http servlet request
Returns:
hashtable of the name value pairs.

getParameter

public static java.lang.String getParameter(HttpServletRequest request,
                                            java.lang.String name)
Returns a parameter as string from the HttpServletRequest.
Parameters:
request - http servlet request
name - the name of the parameter you're looking for
Returns:
parameter string

getSessionID

public static java.lang.String getSessionID(HttpServletRequest req)
Gets the sessoin Id.
Parameters:
req - http servlet request
Returns:
session Is

getURLParameters

public static java.util.Vector getURLParameters(HttpServletRequest request)
Gets the sessoin Id.
Returns:
session Is

getUserRefNum

public static java.lang.Integer getUserRefNum(HttpServletRequest req)
Gets the user reference number.
Parameters:
req - http servlet request
Returns:
user reference number

markTransactionToRollback

public static void markTransactionToRollback()
Marks the current transaction for roll back.

mergeRedirectUrlProperties

public static TypedProperty mergeRedirectUrlProperties(TypedProperty oldProp,
                                                       TypedProperty urlProp)
                                                throws ECApplicationException
Merges the redirect URL parameter with other properties .
Returns:
the final redirect url properties
ECApplicationException

protectQueryString

public static java.lang.String protectQueryString(java.lang.String queryString)
Parses a query string for protected parameters and replaces all protected paramaeter values with "*******"
Parameters:
queryString - query string
Returns:
query string with protected values replaced

rollbackTransaction

public static void rollbackTransaction()
Rolls back the current transaction. This method is to be called when an error is detected in a jsp and the command associated with this jsp has to rollback.

servletRequestToString

public static java.lang.String servletRequestToString(javax.servlet.http.HttpServletRequest request)
Extracts many useful information for debugging purposes from a HttpServletRequest.
Parameters:
request - http servlet request

servletRequestToStringDebug

public static java.lang.String servletRequestToStringDebug(javax.servlet.http.HttpServletRequest request)
Extracts all information useful for debugging purposes from a HttpServletRequest.
Parameters:
request - http servlet request

setEncoding

public static java.lang.String setEncoding(HttpServletRequest req,
                                           java.lang.String defaultEncoding)
Set the encoding for used for retreiving request parameters.
Parameters:
req - http servlet request
defaultEncoding - encoding value

stringToArray

public static java.lang.String[] stringToArray(java.lang.String value)
Converts a string with values seperated by commas to an array of strings.
Parameters:
value - string to be converted to an array
Returns:
array of string

stringToIntegerArray

public static java.lang.Integer[] stringToIntegerArray(java.lang.String[] sarray)
Converts an array of Strings to an array of Integers.
Parameters:
sarray - array of string
Returns:
array of Integer

composeEncodedQueryString

public static java.lang.String composeEncodedQueryString(TypedProperty prop)
Composes a query string from the typedProperties.
Parameters:
prop - type properties
Returns:
the query string

setEncoding

public static void setEncoding(HttpServletRequest req,
                               java.lang.Integer sessionLangId,
                               java.lang.Integer storeId,
                               java.lang.String defaultEncoding)
Sets the encoding to be used to extract the input parameters.
Parameters:
req - the HttpServletRequest object
sessionLangId - language id saved in session
storeId - store Id
defaultEncoding - default encoding

getStoreIdFromQueryString

public static java.lang.Integer getStoreIdFromQueryString(HttpServletRequest req,
                                                          java.lang.Integer defaultStoreId)
Gets the store id fromthe query string.
Parameters:
req - the HttpServletRequest object
defaultStoreId - default store Id
Returns:
store Id

encodeURL

public static java.lang.String encodeURL(java.lang.String val,
                                         java.lang.String encoding)
                                  throws java.io.UnsupportedEncodingException
Encode an url string with a given encoding. Use the default encoding if encoding is null.
Throws:
java.io.UnsupportedEncodingException

decodeURL

public static java.lang.String decodeURL(java.lang.String val,
                                         java.lang.String encoding)
                                  throws java.io.UnsupportedEncodingException
Decode an url string with a given encoding. Use the default encoding if encoding is null.
Throws:
java.io.UnsupportedEncodingException