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:org.swarmcom.jsynapse.controller.client.api.v1.UserRestApi.java

@JsonView(User.DisplayNameSummary.class)
@RequestMapping(value = "/profile/{userId}/displayname", method = GET)
public @ResponseBody User getDisplayName(@PathVariable String userId, HttpServletRequest request) {
    String accessToken = request.getParameter(ACCESS_TOKEN);
    return userService.findLoggedUserById(userId, accessToken);
}

From source file:org.swarmcom.jsynapse.controller.client.api.v1.UserRestApi.java

@JsonView(User.AvatarUrlSummary.class)
@RequestMapping(value = "/profile/{userId}/avatar_url", method = GET)
public @ResponseBody User getAvatarUrl(@PathVariable String userId, HttpServletRequest request) {
    String accessToken = request.getParameter(ACCESS_TOKEN);
    return userService.findLoggedUserById(userId, accessToken);
}

From source file:net.javacrumbs.test.AbstractServlet.java

protected int getMax(HttpServletRequest req) {
    if (req.getParameter(MAX) != null) {
        return Integer.valueOf(req.getParameter(MAX));
    } else {//from  w w w. j ava  2s.  co  m
        return 5000;
    }
}

From source file:org.itracker.web.util.LoginUtilities.java

/**
 * Get a locale from request//from ww w .  ja  va2  s .com
 * <p/>
 * <p>
 * TODO the order of retrieving locale from request should be:
 * <ol>
 * <li>request-attribute Constants.LOCALE_KEY</li>
 * <li>request-param 'loc'</li>
 * <li>session attribute <code>Constants.LOCALE_KEY</code></li>
 * <li>cookie 'loc'</li>
 * <li>request.getLocale()/request.getLocales()</li>
 * <li>ITrackerResources.DEFAULT_LOCALE</li>
 * </ol>
 * </p>
 */
@SuppressWarnings("unchecked")
public static Locale getCurrentLocale(HttpServletRequest request) {
    Locale requestLocale = null;
    HttpSession session = request.getSession(true);
    try {

        requestLocale = (Locale) request.getAttribute(Constants.LOCALE_KEY);

        if (logger.isDebugEnabled()) {
            logger.debug("getCurrentLocale: request-attribute was {}", requestLocale);
        }

        if (null == requestLocale) {
            // get locale from request param
            String loc = request.getParameter("loc");
            if (null != loc && loc.trim().length() > 1) {
                requestLocale = ITrackerResources.getLocale(loc);
            }

            logger.debug("getCurrentLocale: request-parameter was {}", loc);

        }

        if (null == requestLocale) {
            // get it from the session
            requestLocale = (Locale) session.getAttribute(Constants.LOCALE_KEY);
            //            if (logger.isDebugEnabled()) {
            //               logger.debug("getCurrentLocale: session-attribute was "
            //                     + requestLocale);
            //            }
        }

        if (null == requestLocale) {
            ResourceBundle bundle = ITrackerResources.getBundle(request.getLocale());
            if (logger.isDebugEnabled()) {
                logger.debug("getCurrentLocale: trying request header locale " + request.getLocale());
            }
            if (bundle.getLocale().getLanguage().equals(request.getLocale().getLanguage())) {
                requestLocale = request.getLocale();
                if (logger.isDebugEnabled()) {
                    logger.debug("getCurrentLocale: request-locale was " + requestLocale);
                }
            }
        }

        // is there no way to detect supported locales of current
        // installation?

        if (null == requestLocale) {
            Enumeration<Locale> locales = (Enumeration<Locale>) request.getLocales();
            ResourceBundle bundle;
            Locale locale;
            while (locales.hasMoreElements()) {
                locale = locales.nextElement();
                bundle = ITrackerResources.getBundle(locale);

                logger.debug("getCurrentLocale: request-locales processing {}, bundle: {}", locale, bundle);

                if (bundle.getLocale().getLanguage().equals(locale.getLanguage())) {
                    requestLocale = locale;

                    logger.debug("getCurrentLocale: request-locales locale was {}", requestLocale);

                }
            }
        }

    } finally {
        if (null == requestLocale) {
            // fall back to default locale
            requestLocale = ITrackerResources.getLocale();

            logger.debug("getCurrentLocale: fallback default locale was {}", requestLocale);

        }
        session.setAttribute(Constants.LOCALE_KEY, requestLocale);
        request.setAttribute(Constants.LOCALE_KEY, requestLocale);
        request.setAttribute("currLocale", requestLocale);

        logger.debug("getCurrentLocale: request and session was setup with {}", requestLocale);

    }

    return requestLocale;
}

From source file:com.intel.cosbench.controller.web.WorkloadPageController.java

@Override
protected ModelAndView process(HttpServletRequest req, HttpServletResponse res) {
    String id = req.getParameter("id");
    if (StringUtils.isEmpty(id))
        throw new BadRequestException();
    return process(id);
}

From source file:core.controller.KategoriController.java

@RequestMapping(value = "/update", method = RequestMethod.POST)
public String update(HttpServletRequest request) {
    long id = Long.valueOf(request.getParameter("txtId"));
    String kode = request.getParameter("txtKode");
    String nama = request.getParameter("txtNama");
    Kategori kat = new Kategori();
    kat.setId(id);/*from w w w  . j  a va 2 s  . co m*/
    kat.setKode(kode);
    kat.setNama(nama);
    kategoriDAO.update(kat);
    return "redirect:/kategori";
}

From source file:org.ngrinder.security.NgrinderUsernamePasswordAuthenticationFilterTest.java

@Test
public void testFilter() {
    filter.setUserRepository(userRepository);
    HttpServletRequest req = mock(HttpServletRequest.class);
    when(req.getParameter("user_timezone")).thenReturn("Korean");
    when(req.getParameter("native_language")).thenReturn("KoreanLang");
    HttpServletResponse res = mock(HttpServletResponse.class);
    filter.attemptAuthentication(req, res);
    User findOne = userRepository.findOne(getTestUser().getId());
    assertThat(findOne.getUserLanguage(), is("KoreanLang"));
    assertThat(findOne.getTimeZone(), is("Korean"));

}

From source file:org.openmrs.module.muzimabiometrics.web.controller.MuzimafingerPrintManageController.java

@RequestMapping(value = "module/muzimabiometrics/managefingerprint.form", method = RequestMethod.GET)
public void findPatient(HttpServletRequest request, Model model) {
    if (request != null) {
        if (request.getParameter("patientUuid") != null) {
            Patient patient = Context.getPatientService().getPatientByUuid(request.getParameter("patientUuid"));
            if (patient != null) {
                model.addAttribute("identifier", patient.getPatientIdentifier(1));
            }/*from  w w  w.  jav a 2s  .  c o  m*/
        }
    }
}

From source file:org.openmrs.module.muzimafingerPrint.web.controller.MuzimafingerPrintManageController.java

@RequestMapping(value = "module/muzimafingerPrint/managefingerprint.form", method = RequestMethod.GET)
public void findPatient(HttpServletRequest request, Model model) {
    if (request != null) {
        if (request.getParameter("patientUuid") != null) {
            Patient patient = Context.getPatientService().getPatientByUuid(request.getParameter("patientUuid"));
            if (patient != null) {
                model.addAttribute("identifier", patient.getPatientIdentifier(1));
            }//from ww  w.  jav  a2s.  co  m
        }
    }
}

From source file:org.openmrs.web.servlet.DisplayChartServlet.java

protected JFreeChart createChart(HttpServletRequest request, HttpServletResponse response) {

    String key = request.getParameter(CHART_KEY);

    HttpSession session = request.getSession();
    Object o = session.getAttribute(key);

    if (o == null) {
        log.error("Unable to find chart in session with key: " + key);
    }/*  www. ja  va  2  s . c  om*/

    return (JFreeChart) o;

}