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:WebControllers.ControladorFuncionesComunes.java

public int getParametroInt(String parametro, HttpServletRequest request) {
    int param = 0;
    if (request.getParameter(parametro) != null && !request.getParameter(parametro).isEmpty()) {
        try {/*from   www  .  j  a v a  2 s  .co m*/
            param = Integer.parseInt(request.getParameter(parametro));
        } catch (NumberFormatException e) {

        }
    }
    return param;
}

From source file:com.gtwm.pb.servlets.ServletDataMethods.java

public static void addComment(SessionDataInfo sessionData, HttpServletRequest request,
        DatabaseInfo databaseDefn) throws DisallowedException, ObjectNotFoundException, SQLException,
        MissingParametersException, CantDoThatException, CodingErrorException {
    TableInfo table = ServletUtilMethods.getTableForRequest(sessionData, request, databaseDefn, true);
    if (!(databaseDefn.getAuthManager().getAuthenticator().loggedInUserAllowedTo(request,
            PrivilegeType.EDIT_TABLE_DATA, table))) {
        throw new DisallowedException(databaseDefn.getAuthManager().getLoggedInUser(request),
                PrivilegeType.EDIT_TABLE_DATA, table);
    }/*from   w  w  w .ja  v  a  2  s  .co  m*/
    String internalFieldName = request.getParameter("internalfieldname");
    BaseField field = table.getField(internalFieldName);
    String rowIdString = request.getParameter("rowid");
    int rowId = -1;
    if (rowIdString != null) {
        rowId = Integer.valueOf(rowIdString);
    } else {
        rowId = sessionData.getRowId(table);
    }
    AppUserInfo user = databaseDefn.getAuthManager().getLoggedInUser(request);
    String comment = request.getParameter("comment");
    databaseDefn.getDataManagement().addComment(sessionData, field, rowId, user, comment);
}

From source file:de.adorsys.oauth.server.RememberMeMatcher.java

@Override
public boolean match(HttpServerExchange exchange, HttpServletRequest request) {

    String clientId = request.getParameter("client_id");
    if (!request.getRequestURI().endsWith("/auth") || clientId == null) {
        return false;
    }//w w  w . j  ava  2  s . co  m

    Cookie cookieToken = getCookieToken(clientId, request);
    return cookieToken != null;
}

From source file:br.com.insula.spring.security.janrain.JanrainAuthenticationFilterTest.java

@Test
public void testAttemptAuthenticationWithToken() throws Exception {
    HttpServletRequest request = mock(HttpServletRequest.class);
    when(request.getParameter("token")).thenReturn("abcdefg");
    HttpServletResponse response = mock(HttpServletResponse.class);
    JanrainService janrainService = mock(JanrainService.class, RETURNS_MOCKS);
    AuthenticationManager authenticationManager = mock(AuthenticationManager.class, RETURNS_MOCKS);
    filter.setAuthenticationManager(authenticationManager);
    filter.setJanrainService(janrainService);
    assertNotNull(filter.attemptAuthentication(request, response));
}

From source file:com.devnexus.ting.web.controller.admin.UserChangePasswordController.java

@RequestMapping(value = "/s/admin/change-password", method = RequestMethod.POST)
public String changePassword(@Valid UserChangePasswordForm userChangePasswordForm, BindingResult result,
        RedirectAttributes redirectAttributes, HttpServletRequest request) {

    if (request.getParameter("cancel") != null) {
        return "redirect:/s/admin/index";
    }// www . j av  a2s  .c  o m

    if (result.hasErrors()) {
        return "/admin/user-change-password";
    }

    if (userChangePasswordForm.getPassword1().equals(userChangePasswordForm.getPassword2())) {
        userService.changePassword(userChangePasswordForm.getPassword1());
    } else {
        result.reject("Passwords did not match.");
        return "/admin/user-change-password";
    }

    redirectAttributes.addFlashAttribute("successMessage", "The password was changed successfully.");

    return "redirect:/s/admin/index";
}

From source file:za.ac.cput.project.hospitalmanagement.api.MedicineApi.java

@RequestMapping(value = "/updateMedicine", method = RequestMethod.GET)
public String updateMedicine(HttpServletRequest request) {
    String medicineName = request.getParameter("medicineName");
    String medicineType = request.getParameter("medicineType");
    String quantity = request.getParameter("quantity");
    float quantityValue = Float.parseFloat(quantity);
    String treatmentIDParam = request.getParameter("treatmentID");
    Long treatmentID = Long.parseLong(treatmentIDParam);
    String medicineID = request.getParameter("medicineID");
    Long id = Long.parseLong(medicineID);

    return service.updateMedicine(medicineName, medicineType, quantityValue, treatmentID, id);
}

From source file:za.ac.cput.project.hospitalmanagement.api.PatientApi.java

@RequestMapping(value = "/getPatientDetails", method = RequestMethod.GET)
public Patient getPatientDetails(HttpServletRequest request) {
    String patientID = request.getParameter("patientID");
    Long id = Long.parseLong(patientID);
    return service.getPatient(id);
}

From source file:com.collective.celos.servlet.RegisterServlet.java

private RegisterKey getRequestKey(HttpServletRequest req) {
    return new RegisterKey(req.getParameter(CelosClient.KEY_PARAM));
}

From source file:de.u808.simpleinquest.web.usermanagement.UserEditController.java

@Override
protected Object formBackingObject(HttpServletRequest request) throws Exception {
    if (StringUtils.isNotEmpty(request.getParameter("id"))) {
        return userManager.fetchUser(Long.valueOf(request.getParameter("id")));
    } else/* w  ww.  j a v  a 2 s. co m*/
        return super.formBackingObject(request);
}

From source file:com.tsg.sitemapwebappmvc.controller.FactorizorController.java

@RequestMapping(value = "/FactorizorController", method = RequestMethod.POST)
public String getFactorResults(HttpServletRequest request, Model model) {

    Factors factorize = new Factors(Integer.parseInt(request.getParameter("numberToFactor")));
    request.setAttribute("factors", factorize.getFactors());
    request.setAttribute("perfect", factorize.isPerfect());
    request.setAttribute("prime", factorize.isPrime());

    return "factresponse";
}