org.lateralnz.common.util
Class ServletUtils

java.lang.Object
  extended by org.lateralnz.common.util.ServletUtils
All Implemented Interfaces:
Constants

public class ServletUtils
extends java.lang.Object
implements Constants

common utility functions used by servlets


Field Summary
static java.lang.String XML_ATTRIBUTE
           
 
Fields inherited from interface org.lateralnz.common.util.Constants
AMPERSAND, AND, APPLICATION_X_WWW_FORM_URLENCODED, ASTERISK, AT, BACK_SLASH, CHAR_LEFT_CHEV, CHAR_RIGHT_CHEV, COLON, COMMA, DASH, DELETE, DOLLAR, DOT, DOT_CLASS, DOT_JAVA, EIGHT, EMPTY, EQUALS, FALSE, FILE_SEPARATOR, FIVE, FORWARD_SLASH, FOUR, FULLSTOP, HASH, HAT, INSERT, LEFT_BRACE, LEFT_BRACKET, LEFT_CHEV, MAX_LEN_APPCODE, MAX_LEN_APPGROUP, MAX_LEN_MSGCODE, MAX_LEN_MSGTEXT, MINUS_ONE, N, NEWLINE, NINE, NO, NULL_STRING, OFF, ON, ONE, ONE_DAY, ONE_HOUR, ONE_MINUTE, ONE_WEEK, PATH_SEPARATOR, PERCENT, PIPE, PLUS, QUESTION_MARK, QUOTE, REQUIRED, REQUIRES_NEW, RETURN, RIGHT_BRACE, RIGHT_BRACKET, RIGHT_CHEV, SELECT, SEMICOLON, SEVEN, SINGLE_QUOTE, SIX, SPACE, SQ_LEFT_BRACKET, SQ_RIGHT_BRACKET, SUPPORTS, TEXT_HTML, TEXT_PLAIN, TEXT_XML, THREE, TRUE, TWO, UNDERSCORE, UPDATE, UTF_8, Y, YES, ZERO
 
Constructor Summary
protected ServletUtils()
           
 
Method Summary
static void forward(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          check if there is a forward parameter in the http request object, if so, forward on to it
static void forward(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String forwardTag)
          forward a servlet request, based upon a parameter with the name 'forward'
static void forwardError(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          check if there is an error parameter in the http request object, if so, forward on to it
static java.lang.String getAttrOrParam(javax.servlet.http.HttpServletRequest request, java.lang.String name)
          get a named attribute, and if it is not found, look for the parameter instead
static java.io.BufferedReader getBufferedReaderForURL(java.lang.String urlstr, java.util.Map headers, java.lang.String encoding)
           
static java.io.BufferedReader getBufferedReaderForURL(java.lang.String urlstr, java.lang.String encoding)
          get a buffered reader for reading from a specific URL
static java.lang.String getContent(java.lang.String httpmessage)
           
static java.lang.String getHeader(java.lang.String httpmessage)
           
static java.lang.String[] getLanguageCountry(java.lang.String acceptlang)
           
static java.util.Locale getLocale(javax.servlet.http.HttpServletRequest request)
           
static java.util.Locale getLocale(javax.servlet.http.HttpServletRequest request, java.lang.String variant, boolean sessionset)
          get the locale being used by this request
static java.lang.String getParameterFromMap(java.util.Map parameterMap, java.lang.String key, int index)
           
static java.lang.String getServerResponse(java.lang.String host, int port, java.lang.String request, java.lang.String encoding, int timeout)
           
static java.lang.String getServerResponse(java.lang.String url, java.util.Map headers, java.lang.String encoding)
          call another server and return its response as a string
static void main(java.lang.String[] args)
           
static void setLocale(javax.servlet.http.HttpSession session, java.util.Locale locale)
          set the locale for this session
static java.util.Properties toProperties(javax.servlet.ServletConfig config)
          convert a servlet config into a properties file
static java.lang.String toString(javax.servlet.http.HttpServletRequest request)
          convert a servlet request to a string (for debugging purposes)
static java.lang.String toString(javax.servlet.http.HttpSession session)
           
static java.lang.String toString(java.util.Map queryMap)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML_ATTRIBUTE

public static final java.lang.String XML_ATTRIBUTE
See Also:
Constant Field Values
Constructor Detail

ServletUtils

protected ServletUtils()
Method Detail

forward

public static final void forward(javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response,
                                 java.lang.String forwardTag)
forward a servlet request, based upon a parameter with the name 'forward'


forward

public static final void forward(javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response)
check if there is a forward parameter in the http request object, if so, forward on to it

Parameters:
request - the servlet request
response - the servlet response

forwardError

public static final void forwardError(javax.servlet.http.HttpServletRequest request,
                                      javax.servlet.http.HttpServletResponse response)
check if there is an error parameter in the http request object, if so, forward on to it

Parameters:
request - the servlet request
response - the servlet response

getAttrOrParam

public static final java.lang.String getAttrOrParam(javax.servlet.http.HttpServletRequest request,
                                                    java.lang.String name)
get a named attribute, and if it is not found, look for the parameter instead


getBufferedReaderForURL

public static final java.io.BufferedReader getBufferedReaderForURL(java.lang.String urlstr,
                                                                   java.lang.String encoding)
                                                            throws java.net.MalformedURLException,
                                                                   java.io.IOException
get a buffered reader for reading from a specific URL

Throws:
java.net.MalformedURLException
java.io.IOException

getBufferedReaderForURL

public static final java.io.BufferedReader getBufferedReaderForURL(java.lang.String urlstr,
                                                                   java.util.Map headers,
                                                                   java.lang.String encoding)
                                                            throws java.net.MalformedURLException,
                                                                   java.io.IOException
Throws:
java.net.MalformedURLException
java.io.IOException

getContent

public static final java.lang.String getContent(java.lang.String httpmessage)

getHeader

public static final java.lang.String getHeader(java.lang.String httpmessage)

getLanguageCountry

public static final java.lang.String[] getLanguageCountry(java.lang.String acceptlang)

getLocale

public static final java.util.Locale getLocale(javax.servlet.http.HttpServletRequest request)

getLocale

public static final java.util.Locale getLocale(javax.servlet.http.HttpServletRequest request,
                                               java.lang.String variant,
                                               boolean sessionset)
get the locale being used by this request


getServerResponse

public static final java.lang.String getServerResponse(java.lang.String url,
                                                       java.util.Map headers,
                                                       java.lang.String encoding)
                                                throws java.net.MalformedURLException,
                                                       java.io.IOException
call another server and return its response as a string

Throws:
java.net.MalformedURLException
java.io.IOException

getParameterFromMap

public static java.lang.String getParameterFromMap(java.util.Map parameterMap,
                                                   java.lang.String key,
                                                   int index)

getServerResponse

public static final java.lang.String getServerResponse(java.lang.String host,
                                                       int port,
                                                       java.lang.String request,
                                                       java.lang.String encoding,
                                                       int timeout)
                                                throws java.io.IOException
Throws:
java.io.IOException

setLocale

public static final void setLocale(javax.servlet.http.HttpSession session,
                                   java.util.Locale locale)
set the locale for this session


toProperties

public static final java.util.Properties toProperties(javax.servlet.ServletConfig config)
convert a servlet config into a properties file


toString

public static final java.lang.String toString(javax.servlet.http.HttpServletRequest request)
convert a servlet request to a string (for debugging purposes)


toString

public static final java.lang.String toString(javax.servlet.http.HttpSession session)

toString

public static final java.lang.String toString(java.util.Map queryMap)

main

public static final void main(java.lang.String[] args)
                       throws java.lang.Exception
Throws:
java.lang.Exception