Example usage for javax.servlet ServletRequest getParameter

List of usage examples for javax.servlet ServletRequest getParameter

Introduction

In this page you can find the example usage for javax.servlet ServletRequest getParameter.

Prototype

public String getParameter(String name);

Source Link

Document

Returns the value of a request parameter as a String, or null if the parameter does not exist.

Usage

From source file:org.apache.sentry.api.service.thrift.PubSubServlet.java

/**
 * Return parameter on servlet request for the given name
 *
 * @param request: Servlet request//  w ww .j  a va  2  s. c o  m
 * @param name: Name of parameter in servlet request
 * @return Parameter in servlet request for the given name, return null if can't find parameter.
 */
private static String getParameter(ServletRequest request, String name) {
    String s = request.getParameter(name);
    if (s == null) {
        return null;
    }
    s = s.trim();
    return s.isEmpty() ? null : s;
}

From source file:org.punksearch.web.SearchParams.java

public static String getStringValue(ServletRequest request, String paramName) {
    String paramValue = request.getParameter(paramName);
    if (paramValue == null)
        return "";

    //        OMG WTF??? this prevents russian queries!
    /*      try {/*from   ww  w.ja v  a2s  . c o m*/
             paramValue = new String(paramValue.getBytes("ISO-8859-1"), "UTF-8");
          } catch (UnsupportedEncodingException uee) {
             log.warn(uee.getMessage());
          }*/

    return paramValue;
}

From source file:org.apache.hadoop.util.ServletUtil.java

/**
 * Get a parameter from a ServletRequest.
 * Return null if the parameter contains only white spaces.
 */// w  w  w .j  a v a  2 s .  c  om
public static String getParameter(ServletRequest request, String name) {
    String s = request.getParameter(name);
    if (s == null) {
        return null;
    }
    s = s.trim();
    return s.length() == 0 ? null : s;
}

From source file:org.punksearch.web.SearchParams.java

public static Double getDoubleValue(ServletRequest request, String paramName, Double byDefault) {
    String paramValue = request.getParameter(paramName);
    if (paramValue == null || paramValue.equals(""))
        return byDefault;

    return Double.valueOf(paramValue);

}

From source file:org.punksearch.web.SearchParams.java

public static Integer getIntegerValue(ServletRequest request, String paramName, Integer byDefault) {
    String paramValue = request.getParameter(paramName);
    if (paramValue == null || paramValue.equals(""))
        return byDefault;

    return Integer.valueOf(paramValue);

}

From source file:org.punksearch.web.SearchParams.java

public static Boolean getBooleanValue(ServletRequest request, String paramName, Boolean byDefault) {
    String paramValue = request.getParameter(paramName);
    if (paramValue == null || paramValue.equals(""))
        return byDefault;

    return paramValue.equals("true") || paramValue.equals("on");

}

From source file:org.apache.hadoop.util.ServletUtil.java

/**
 * @return a long value as passed in the given parameter, throwing
 * an exception if it is not present or if it is not a valid number.
 *///from  ww  w.  j  a  v a2s  . co  m
public static long parseLongParam(ServletRequest request, String param) throws IOException {
    String paramStr = request.getParameter(param);
    if (paramStr == null) {
        throw new IOException("Invalid request has no " + param + " parameter");
    }

    return Long.parseLong(paramStr);
}

From source file:com.redhat.rhn.frontend.taglibs.list.decorators.PageSizeDecorator.java

/**
 * Returns true if the page size widget was selected
 * @param request the http  servlet request
 * @param listName the name of the list//from   w w  w . j av  a  2s .com
 * @return true if the page size widget was selected
 */
public static boolean pageWidgetSelected(ServletRequest request, String listName) {
    return SELECTED.equals(request.getParameter(makeSelectionLabel(listName)));
}

From source file:org.rhq.enterprise.gui.util.WebUtility.java

public static Integer getResourceGroupId(ServletRequest request) {
    String groupIdString = request.getParameter(ParamConstants.GROUP_ID_PARAM);
    Integer groupId = null;/*from  w  ww  .j av a  2 s.c  o  m*/
    if (groupIdString != null && !groupIdString.equals("")) {
        groupId = Integer.parseInt(groupIdString);
    }

    return groupId;
}

From source file:org.rhq.enterprise.gui.util.WebUtility.java

public static Integer getResourceId(ServletRequest request) {
    String resourceIdString = request.getParameter(ParamConstants.CURRENT_RESOURCE_ID_PARAM);
    if (resourceIdString == null || resourceIdString.equals("")) {
        resourceIdString = request.getParameter(ParamConstants.RESOURCE_ID_PARAM);
    }/*ww w  .  ja  v  a 2 s  . co  m*/
    Integer resourceId = null;
    if (resourceIdString != null && !resourceIdString.equals("")) {
        resourceId = Integer.parseInt(resourceIdString);
    }

    return resourceId;
}