com.pow2.util
Class ServletUtil

java.lang.Object
  extended bycom.pow2.util.ServletUtil

public class ServletUtil
extends Object

Servlet Utility class

Author:
Luca Fossato

Constructor Summary
ServletUtil()
           
 
Method Summary
static String buildQueryString(HttpServletRequest request, String[] args)
          Build a query string using the (parameter, value) couples retrieved from the input request object.
static String dumpRequest(HttpServletRequest req)
          Dumps all the incoming HttpServletRequest informations.
static String getBase(HttpServletRequest req)
          Get the String representation of the HTTP URL for the input servlet.
static String getContent(HttpServletRequest req, String path)
          Get the content of the file retrieved from the input path.
static String getRequestAttribute(HttpServletRequest req, String attribute)
          Get the input request parameter or attribute string value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletUtil

public ServletUtil()
Method Detail

buildQueryString

public static String buildQueryString(HttpServletRequest request,
                                      String[] args)
Build a query string using the (parameter, value) couples retrieved from the input request object.

Parameters:
request - the HttpServletRequest object
args - the String array containing the name of the request parameters to retrieve
Returns:
the HTTP query string

dumpRequest

public static String dumpRequest(HttpServletRequest req)
Dumps all the incoming HttpServletRequest informations.

Parameters:
req - the input HttpServletRequest object to dump
Returns:
a string with dumped information

getBase

public static String getBase(HttpServletRequest req)
                      throws Exception
Get the String representation of the HTTP URL for the input servlet.

Parameters:
req - the HttpServletRequest object.
Returns:
the String representation of the HTTP URL for the input servlet.
Throws:
Exception - if the URL conversion fails.

getContent

public static String getContent(HttpServletRequest req,
                                String path)
                         throws Exception
Get the content of the file retrieved from the input path.

Parameters:
req - the HttpServletRequest object
path - the path of the resource file to read
Returns:
The content value
Throws:
Exception - if any error occurs

getRequestAttribute

public static String getRequestAttribute(HttpServletRequest req,
                                         String attribute)
Get the input request parameter or attribute string value.
First try to retrieve the request parameter; if it does not exists or have a "null" value, retrieve the relative request attribute (if any).
Note: for HTTP servlets, parameters are contained in the query string or posted form data, while attributes are request embedded informations.

Parameters:
req - the HttpServletRequest object
attribute - the attribute to retrieve from the request object
Returns:
the input request parameter / attribute string value, or null if the input attribute doesn't match any request parameter / attribute


Copyright © 2002-2004 Power Of Two S.R.L. All Rights Reserved.