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:at.gv.egovernment.moa.id.auth.parser.StartAuthentificationParameterParser.java

public static void parse(HttpServletRequest req, HttpServletResponse resp, AuthenticationSession moasession,
        IRequest request) throws WrongParametersException, MOAIDException {

    String modul = request.requestedModule();//req.getParameter(PARAM_MODUL);
    String action = request.requestedAction();//req.getParameter(PARAM_ACTION);

    modul = StringEscapeUtils.escapeHtml(modul);
    action = StringEscapeUtils.escapeHtml(action);
    if (modul == null) {
        modul = SAML1Protocol.PATH;/*from w w w  .j  a v  a 2 s  .c om*/
    }

    if (action == null) {
        action = SAML1Protocol.GETARTIFACT;
    }
    moasession.setModul(modul);
    moasession.setAction(action);

    //get Parameters from request
    String target = req.getParameter(PARAM_TARGET);
    String oaURL = req.getParameter(PARAM_OA);
    String bkuURL = req.getParameter(PARAM_BKU);
    String templateURL = req.getParameter(PARAM_TEMPLATE);
    String useMandate = req.getParameter(PARAM_USEMANDATE);
    String ccc = req.getParameter(PARAM_CCC);

    oaURL = request.getOAURL();
    target = request.getTarget();

    parse(moasession, target, oaURL, bkuURL, templateURL, useMandate, ccc, modul, action, req);

}

From source file:fr.paris.lutece.portal.service.util.AppPathService.java

/**
 * Gets a Virtual Host Key if the request contains a virtual host key
 *
 * @param request The HTTP request/*  w  ww.  j ava  2s  .  c om*/
 * @return A Virtual Host Key if present, otherwise null.
 */
public static String getVirtualHostKey(HttpServletRequest request) {
    String strVirtalHostKey = null;

    // Get from config.properties the parameter name for virtual host keys
    String strVirtualHostKeyParameter = AppPropertiesService.getProperty(PROPERTY_VIRTUAL_HOST_KEY_PARAMETER);

    if ((request != null) && (strVirtualHostKeyParameter != null) && (!strVirtualHostKeyParameter.equals(""))) {
        // Search for this parameter into the request
        strVirtalHostKey = request.getParameter(strVirtualHostKeyParameter);
    }

    return strVirtalHostKey;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.vendors.VendorHelper.java

/**
 * Save the request parameters from the Contact Info page
 *///w  w  w.j  av a2 s .  c o m
public static void saveContactInfo(Vendor vendor, HttpServletRequest request) {
    String buf = null;
    buf = (String) request.getParameter("address");
    if (buf != null)
        vendor.setAddress(buf);
    buf = (String) request.getParameter("country");
    if (buf != null)
        vendor.setCountry(buf);
    buf = (String) request.getParameter("homePhone");
    if (buf != null)
        vendor.setPhoneNumber(User.PhoneType.HOME, buf);
    buf = (String) request.getParameter("workPhone");
    if (buf != null)
        vendor.setPhoneNumber(User.PhoneType.OFFICE, buf);
    buf = (String) request.getParameter("cellPhone");
    if (buf != null)
        vendor.setPhoneNumber(User.PhoneType.CELL, buf);
    buf = (String) request.getParameter("fax");
    if (buf != null)
        vendor.setPhoneNumber(User.PhoneType.FAX, buf);
    buf = (String) request.getParameter("email");
    if (buf != null)
        vendor.setEmail(buf);
    buf = (String) request.getParameter("uiLocale");
    if (buf != null)
        vendor.setDefaultUILocale(buf);
}

From source file:com.icl.integrator.util.patch.ServletAnnotationMappingUtils.java

/**
 * Check whether the given request matches the specified parameter conditions.
 * @param params  the parameter conditions, following
 * {@link org.springframework.web.bind.annotation.RequestMapping#params() RequestMapping.#params()}
 * @param request the current HTTP request to check
 *///from w  ww. j ava  2 s. c o  m
public static boolean checkParameters(String[] params, HttpServletRequest request) {
    if (!ObjectUtils.isEmpty(params)) {
        for (String param : params) {
            int separator = param.indexOf('=');
            if (separator == -1) {
                if (param.startsWith("!")) {
                    if (WebUtils.hasSubmitParameter(request, param.substring(1))) {
                        return false;
                    }
                } else if (!WebUtils.hasSubmitParameter(request, param)) {
                    return false;
                }
            } else {
                boolean negated = separator > 0 && param.charAt(separator - 1) == '!';
                String key = !negated ? param.substring(0, separator) : param.substring(0, separator - 1);
                String value = param.substring(separator + 1);
                boolean match = value.equals(request.getParameter(key));
                if (negated) {
                    match = !match;
                }
                if (!match) {
                    return false;
                }
            }
        }
    }
    return true;
}

From source file:controlador.AgregarPruebaControlador.java

@RequestMapping(value = "/formulario", method = RequestMethod.POST)
public String loginasd(ModelMap model, HttpServletRequest request) {
    String nombre = request.getParameter("nombre");
    String numero = request.getParameter("numero");
    model.addAttribute("nombre", nombre);
    model.addAttribute("numero", numero);
    return "pruebaNueva";
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.vendors.VendorHelper.java

/**
 * Save the request parameters from the projects page
 *//*  w  w  w .j a  v  a  2 s .  com*/
public static void saveProjects(Vendor vendor, HttpServletRequest request) throws EnvoyServletException {
    String toField = (String) request.getParameter("toField");
    ArrayList projects = new ArrayList();
    if (toField != null) {
        if (toField.equals("")) {
            vendor.setProjects(null);
        } else {
            try {
                String[] projIds = toField.split(",");
                for (int i = 0; i < projIds.length; i++) {
                    Project proj = ServerProxy.getProjectHandler().getProjectById(Long.parseLong(projIds[i]));
                    projects.add(proj);
                }
                vendor.setProjects(projects);
            } catch (Exception ge) {
                throw new EnvoyServletException(ge);
            }
        }
    }

    PermissionSet permSet = (PermissionSet) request.getSession(false).getAttribute(WebAppConstants.PERMISSIONS);

    if (permSet.getPermissionFor(Permission.USERS_PROJECT_MEMBERSHIP) == true) {
        if (request.getParameter("allProjects") != null) {
            vendor.isInAllProjects(true);
        } else {
            vendor.isInAllProjects(false);
        }
    }
}

From source file:com.erudika.para.utils.Utils.java

/**
 * Checks if a request comes from JavaScript.
 * @param request HTTP request/*from  w  ww .j a v  a  2 s.  c  o m*/
 * @return true if AJAX
 */
public static boolean isAjaxRequest(HttpServletRequest request) {
    return "XMLHttpRequest".equalsIgnoreCase(request.getHeader("X-Requested-With"))
            || "XMLHttpRequest".equalsIgnoreCase(request.getParameter("X-Requested-With"));
}

From source file:com.faces.controller.CaptureController.java

@RequestMapping(value = "/set/rollnumber", method = RequestMethod.POST)
public ModelAndView setRollnumber(HttpServletRequest request) {
    String roll = request.getParameter("tbRollNumber");
    System.out.println("....................rollNumber = " + roll);
    mav = new ModelAndView("upload");
    return mav;//from   www  . j  a  v a 2 s.c  o m
}

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

@RequestMapping(value = "/addRoom", method = RequestMethod.GET)
public String SaveRoom(HttpServletRequest request) {
    String totalBeds = request.getParameter("totalBeds");
    int totalBedsValue = Integer.parseInt(totalBeds);
    String availableBeds = request.getParameter("availableBeds");
    int availableBedsValue = Integer.parseInt(availableBeds);
    String roomType = request.getParameter("roomType");
    return service.saveRoom(totalBedsValue, availableBedsValue, roomType);
}

From source file:fll.web.DoLogin.java

/**
 * Does the work of login. Exists as a separate method so that it can be
 * called from {@link fll.web.admin.CreateUser}
 *//*from  w ww .  ja  v  a  2s  .c o m*/
public static void doLogin(final HttpServletRequest request, final HttpServletResponse response,
        final ServletContext application, final HttpSession session) throws IOException, ServletException {
    final DataSource datasource = ApplicationAttributes.getDataSource(application);
    Connection connection = null;
    try {
        connection = datasource.getConnection();

        // check for authentication table
        if (Queries.isAuthenticationEmpty(connection)) {
            LOGGER.warn("No authentication information in the database");
            session.setAttribute(SessionAttributes.MESSAGE,
                    "<p class='error'>No authentication information in the database - see administrator</p>");
            response.sendRedirect(response.encodeRedirectURL("login.jsp"));
            return;
        }

        // compute hash
        final String user = request.getParameter("user");
        final String pass = request.getParameter("pass");
        if (null == user || user.isEmpty() || null == pass || pass.isEmpty()) {
            LOGGER.warn("Form fields missing");
            session.setAttribute(SessionAttributes.MESSAGE,
                    "<p class='error'>You must fill out all fields in the form.</p>");
            response.sendRedirect(response.encodeRedirectURL("login.jsp"));
            return;
        }
        final String hashedPass = DigestUtils.md5Hex(pass);

        // compare login information
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Checking user: " + user + " hashedPass: " + hashedPass);
        }
        final Map<String, String> authInfo = Queries.getAuthInfo(connection);
        for (final Map.Entry<String, String> entry : authInfo.entrySet()) {
            if (user.equals(entry.getKey()) && hashedPass.equals(entry.getValue())) {
                // clear out old login cookies first
                CookieUtils.clearLoginCookies(application, request, response);

                final String magicKey = String.valueOf(System.currentTimeMillis());
                Queries.addValidLogin(connection, user, magicKey);
                CookieUtils.setLoginCookie(response, magicKey);

                String redirect = SessionAttributes.getRedirectURL(session);
                if (null == redirect) {
                    redirect = "index.jsp";
                }
                response.sendRedirect(response.encodeRedirectURL(redirect));
                return;
            } else {
                if (LOGGER.isTraceEnabled()) {
                    LOGGER.trace("Didn't match user: " + entry.getKey() + " pass: " + entry.getValue());
                }
            }
        }

        LOGGER.warn("Incorrect login credentials user: " + user);
        session.setAttribute(SessionAttributes.MESSAGE,
                "<p class='error'>Incorrect login information provided</p>");
        response.sendRedirect(response.encodeRedirectURL("login.jsp"));
        return;
    } catch (final SQLException e) {
        throw new RuntimeException(e);
    } finally {
        SQLFunctions.close(connection);
    }
}