com.mindoo.xpages2eclipse.tools
Class ServletHelper

java.lang.Object
  extended by com.mindoo.xpages2eclipse.tools.ServletHelper

public class ServletHelper
extends java.lang.Object

Helper methods for servlet I/O operations


Constructor Summary
ServletHelper()
           
 
Method Summary
static double getParamDouble(HttpServletRequest req, java.lang.String param, double defaultValue)
          Convenience method to read a double value from the query string
static int getParamInt(HttpServletRequest req, java.lang.String param, int defaultValue)
          Convenience method to read an int value from the query string
static java.lang.String getParamString(HttpServletRequest req, java.lang.String param, java.lang.String defaultValue)
          Convenience method to read a String value from the query string
static java.lang.String readPostDataAsText(HttpServletRequest req)
          This method reads POST data that contains character data
static void sendHttpError(HttpServletResponse response, int errCode, java.lang.String errMsg, java.lang.Throwable t)
          Sends a http error code to the specified HttpServletResponse
 
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

readPostDataAsText

public static java.lang.String readPostDataAsText(HttpServletRequest req)
                                           throws java.io.IOException
This method reads POST data that contains character data

Parameters:
req - servlet request
Returns:
post content
Throws:
java.io.IOException

sendHttpError

public static void sendHttpError(HttpServletResponse response,
                                 int errCode,
                                 java.lang.String errMsg,
                                 java.lang.Throwable t)
Sends a http error code to the specified HttpServletResponse

Parameters:
response - servlet response
errCode - e.g. 404 or 500
errMsg - error message, can be null
t - an optional exception, can be null
Throws:
ServletException
java.io.IOException

getParamInt

public static int getParamInt(HttpServletRequest req,
                              java.lang.String param,
                              int defaultValue)
Convenience method to read an int value from the query string

Parameters:
req - servlet request
param - query string parameter name
defaultValue - default value of parameter is not defined
Returns:
value

getParamDouble

public static double getParamDouble(HttpServletRequest req,
                                    java.lang.String param,
                                    double defaultValue)
Convenience method to read a double value from the query string

Parameters:
req - servlet request
param - query string parameter name
defaultValue - default value of parameter is not defined
Returns:
value

getParamString

public static java.lang.String getParamString(HttpServletRequest req,
                                              java.lang.String param,
                                              java.lang.String defaultValue)
Convenience method to read a String value from the query string

Parameters:
req - servlet request
param - query string parameter name
defaultValue - default value of parameter is not defined
Returns:
value