Example usage for javax.servlet.http HttpServletRequest getParameter

List of usage examples for javax.servlet.http HttpServletRequest getParameter

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest 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:com.ikon.util.WebUtils.java

/**
 * Extrae un parmetro de tipo booleano del request. 
 * Si el parmetro existe y no esta vacio devuelve true, en caso contrario devuelve false.
 * @param request Peticin de la que extraer el parmetro.
 * @param name Nombre del parmetro//from   ww w.ja  v a  2s.  co m
 * @return true si el parmetro existe y no esta vacio, false en caso contrario.
 */
public static final boolean getBoolean(HttpServletRequest request, String name) {
    String strValue = request.getParameter(name);
    return (strValue != null && !strValue.equals(EMPTY_STRING) && !strValue.equals("false"));
}

From source file:gov.nih.nci.cabig.caaers.web.utils.WebUtils.java

public static String getStringParameter(HttpServletRequest request, String param) {
    String value = request.getParameter(param);
    if (value == null)
        value = "";
    return value;
}

From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Admin.CUDEventos.java

protected static void actualizarConvocatoria(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    ArrayList r = CtrlAdmin.actualizarConvocatoria(Integer.parseInt(request.getParameter("0")), // id
            request.getParameter("1"), // nombre
            request.getParameter("2"), // descripcin
            request.getParameter("4"), // fin
            Integer.parseInt(request.getParameter("6")) // cupos
    );//from w  w w.  jav a2 s.  c o  m

    response.setContentType("application/json;charset=UTF-8");
    PrintWriter out = response.getWriter();
    if (r.get(0) == "error") {
        JSONObject obj = new JSONObject();
        obj.put("isError", true);
        obj.put("errorDescrip", r.get(1));
        out.print(obj);
    } else if (r.get(0) == "isExitoso") {
        JSONObject obj = new JSONObject();
        obj.put("Exitoso", true);
        out.print(obj);
    } else
        Util.errordeRespuesta(r, out);
}

From source file:com.activecq.api.utils.HttpRequestUtil.java

/**
 * <p>/*from w  ww  . jav a  2s . c o m*/
 * Gets the Attribute or Parameter value from the Request.
 * </p><p>
 * Attribute takes precedence
 * </p><p>
 * If neither a Parameter or Attribute value exists @ key, return the dfault
 * </p>
 *
 * @param request
 * @param key
 * @param dfault
 * @return
 */
public static String getParameterOrAttribute(HttpServletRequest request, String key, String dfault) {
    String value = null;
    if (request == null) {
        return value;
    }

    if (hasParameter(request, key)) {
        value = request.getParameter(key);
    } else if (hasAttribute(request, key)) {
        value = (String) request.getAttribute(key);
    }

    if (StringUtils.isBlank(value)) {
        value = dfault;
    }

    return value;
}

From source file:com.sun.licenseserver.License.java

public static License getLicenseFromDatabase(HttpServletRequest req) throws LicenseServerException {
    String userId = req.getParameter("userId");
    String contentId = req.getParameter("contentId");
    String shopId = req.getParameter("shopId");
    verifyLicenseFields(userId, contentId, shopId);
    return License.getLicenseFromDatabase(userId, contentId, shopId);
}

From source file:com.bluepandora.therap.donatelife.service.BloodRequestService.java

public static void removeBloodRequest(HttpServletRequest request, HttpServletResponse response)
        throws JSONException {
    DatabaseService dbService = new DatabaseService(DRIVER_NAME, DATABASE_URL, USERNAME, PASSWORD);

    String requestName = request.getParameter("requestName");
    JSONObject jsonObject = null;/*from w  w w.java2 s .  c  o  m*/

    if (request.getParameter("mobileNumber") != null && request.getParameter("reqTime") != null) {
        String mobileNumber = request.getParameter("mobileNumber");
        String reqTime = request.getParameter("reqTime");
        if (DataValidation.isValidMobileNumber(mobileNumber) && DataValidation.isValidString(reqTime)) {
            String query = GetQuery.removeBloodRequestQuery(mobileNumber, reqTime);
            // Debug.debugLog("DELETE BLOOD REQUEST QUERY:", query);
            dbService.databaseOpen();
            boolean done = dbService.queryExcute(query);
            dbService.databaseClose();
            if (done) {
                jsonObject = LogMessageJson.getLogMessageJson(Enum.CORRECT, Enum.MESSAGE_REMOVED_BLOOD_REQUEST,
                        requestName);
                Debug.debugLog("MOBILE NUMBER: ", mobileNumber, " REMOVE BLOOD REQUEST SUCCESS");
            } else {
                jsonObject = LogMessageJson.getLogMessageJson(Enum.ERROR, Enum.MESSAGE_ERROR, requestName);
            }
        } else {
            jsonObject = LogMessageJson.getLogMessageJson(Enum.ERROR, Enum.MESSAGE_INVALID_VALUE, requestName);
        }
    } else {
        jsonObject = LogMessageJson.getLogMessageJson(Enum.ERROR, Enum.MESSAGE_LESS_PARAMETER, requestName);
    }
    SendJsonData.sendJsonData(request, response, jsonObject);

}

From source file:com.ikon.util.WebUtils.java

/**
 * Extrae un parmetro de tipo String del request. Si el parmetro no existe devuelve
 * un String vacio.//from www .  j a va2  s  .co m
 * @param request Peticin de la que extraer el parmetro.
 * @param name Nombre del parmetro
 * @return El valor String del parmetro o un String vacio si no existe.
 */
public static final String getString(HttpServletRequest request, String name) {
    String value = request.getParameter(name);
    String stringValue = EMPTY_STRING;

    if (value != null) {
        try {
            return new String(value.getBytes("ISO-8859-1"), "UTF-8").trim();
        } catch (UnsupportedEncodingException e) {
            // Ignore
        }
    }

    return stringValue;
}

From source file:com.streak.logging.analysis.AnalysisUtility.java

public static String extractParameterOrThrow(HttpServletRequest req, String paramName) {
    String param = req.getParameter(paramName);
    if (!areParametersValid(param)) {
        throw new InvalidTaskParameterException("Couldn't find required parameter " + paramName);
    }//  w  w  w.  j  a  va2 s .  c o  m
    return param;
}

From source file:com.bluepandora.therap.donatelife.adminpanel.AdminService.java

public static void getAdminList(HttpServletRequest request, HttpServletResponse response) throws JSONException {
    DatabaseService dbService = new DatabaseService(DRIVER_NAME, DATABASE_URL, USERNAME, PASSWORD);
    dbService.databaseOpen();/*from  ww  w .j  a v  a2 s. c o  m*/
    String requestName = request.getParameter("requestName");
    JSONObject jsonObject = null;
    String query = AdminQuery.getAdminListQuery();
    Debug.debugLog("AdminList  QUERY : ", query);
    ResultSet result = dbService.getResultSet(query);
    jsonObject = JsonBuilder.getAdminListJson(result);
    jsonObject = RequestNameAdderJson.setRequestNameInJson(jsonObject, requestName);
    SendJsonData.sendJsonData(request, response, jsonObject);
    dbService.databaseClose();
}

From source file:com.bluepandora.therap.donatelife.service.UserRegistrationService.java

public static void updateUserPersonalInfo(HttpServletRequest request, HttpServletResponse response)
        throws JSONException {
    DatabaseService dbService = new DatabaseService(DRIVER_NAME, DATABASE_URL, USERNAME, PASSWORD);

    String requestName = request.getParameter("requestName");
    JSONObject jsonObject = null;/*from   ww  w  . j  ava  2s. c  o  m*/

    if (request.getParameter("mobileNumber") != null && request.getParameter("groupId") != null
            && request.getParameter("distId") != null && request.getParameter("firstName") != null
            && request.getParameter("lastName") != null && request.getParameter("keyWord") != null) {

        String firstName = request.getParameter("firstName").toUpperCase();
        String lastName = request.getParameter("lastName").toUpperCase();
        String distId = request.getParameter("distId");
        String groupId = request.getParameter("groupId");
        String keyWord = request.getParameter("keyWord");
        String mobileNumber = request.getParameter("mobileNumber");

        if (DataValidation.isValidMobileNumber(mobileNumber) && DataValidation.isValidKeyWord(keyWord)
                && DataValidation.isValidLength(firstName, 45) && DataValidation.isValidLength(lastName, 45)) {

            String hashKey = DataValidation.encryptTheKeyWord(keyWord);
            dbService.databaseOpen();

            boolean validUser = CheckService.isValidUser(mobileNumber, hashKey, dbService);
            if (validUser) {
                AddPersonName.addPersonName(firstName, lastName, dbService);
                String query = GetQuery.updatePersonInfoQuery(mobileNumber, hashKey, firstName, lastName,
                        groupId, distId);
                boolean done = dbService.queryExcute(query);
                if (done) {
                    jsonObject = LogMessageJson.getLogMessageJson(Enum.CORRECT, Enum.MESSAGE_INFO_UPDATED);
                    Debug.debugLog("MOBILE NUMBER: ", mobileNumber, " UPDATE USER PROFILE SCCEUSS");
                } else {
                    jsonObject = LogMessageJson.getLogMessageJson(Enum.ERROR, Enum.MESSAGE_ERROR);
                }
            } else {
                jsonObject = LogMessageJson.getLogMessageJson(Enum.ERROR, Enum.MESSAGE_INVALID_USER);
            }

            dbService.databaseClose();
        } else {
            jsonObject = LogMessageJson.getLogMessageJson(Enum.ERROR, Enum.MESSAGE_INVALID_VALUE);
        }

    } else {
        jsonObject = LogMessageJson.getLogMessageJson(Enum.ERROR, Enum.MESSAGE_LESS_PARAMETER);
    }

    jsonObject = RequestNameAdderJson.setRequestNameInJson(jsonObject, requestName);
    SendJsonData.sendJsonData(request, response, jsonObject);

}