List of usage examples for javax.servlet.http HttpServletRequest getParameter
public String getParameter(String name);
String
, or null
if the parameter does not exist. From source file:ispyb.client.common.util.FileUtil.java
/** * returns the value of the give param in the request * try to fix character '+' in the request (filename) * @param request/*from ww w . j av a 2s. com*/ * @param param * @return */ public static String getRequestParameter(HttpServletRequest request, String param) { String value = request.getParameter(param); String query = request.getQueryString(); int id = query.indexOf(param); if (id != -1) { String paramValue = query.substring(1 + id + param.length()); int idA = paramValue.indexOf('&'); if (idA != -1) { paramValue = paramValue.substring(0, idA); } value = paramValue; } return value; }
From source file:com.attribyte.essem.util.Util.java
/** * Gets a string parameter from the request with a default value. * @param request The request.//from ww w. j a v a 2 s. co m * @param name The parameter name. * @param defaultValue The default value. * @return The parameter or default value. */ public static final String getParameter(final HttpServletRequest request, final String name, final String defaultValue) { String strVal = Strings.nullToEmpty(request.getParameter(name)).trim(); return strVal.isEmpty() ? defaultValue : strVal; }
From source file:com.attribyte.essem.util.Util.java
/** * Gets a boolean parameter from the request with a default value. * @param request The request.// ww w. j ava 2 s . c o m * @param name The parameter name. * @param defaultValue The default value. * @return The parameter or default value. */ public static final boolean getParameter(final HttpServletRequest request, final String name, final boolean defaultValue) { String strVal = Strings.nullToEmpty(request.getParameter(name)).trim(); return strVal.isEmpty() ? defaultValue : strVal.equalsIgnoreCase("true"); }
From source file:fr.paris.lutece.portal.web.PortalJspBean.java
/** * Do send a resource// www .ja v a2 s. com * @param request The request * @return The HTML content to display * @throws SiteMessageException If the resource or its associated service is * not found */ public static String sendResource(HttpServletRequest request) throws SiteMessageException { String strSenderEmail = request.getParameter(PARAMETER_SENDER_EMAIL); String strSenderName = request.getParameter(PARAMETER_SENDER_NAME); String strSenderFirstName = request.getParameter(PARAMETER_SENDER_FIRST_NAME); String strReceipientEmail = request.getParameter(Parameters.EMAIL); String strContent = request.getParameter(PARAMETER_CONTENT); String strExtendableResourceType = request.getParameter(PARAMETER_EXTENDABLE_RESOURCE_TYPE); String strIdExtendableResource = request.getParameter(PARAMETER_ID_EXTENDABLE_RESOURCE); String strSend = request.getParameter(PARAMETER_SEND); IExtendableResource resource = null; String strError = null; // If the form was submited, we check data if (strSend != null) { if (StringUtils.isEmpty(strSenderEmail) || StringUtils.isEmpty(strSenderName) || StringUtils.isEmpty(strSenderFirstName) || StringUtils.isEmpty(strReceipientEmail) || StringUtils.isEmpty(strContent)) { strError = I18nService.getLocalizedString(MESSAGE_ERROR_MANDATORY_FIELDS, request.getLocale()); } if ((strError != null) && (!AdminUserService.checkEmail(strSenderEmail) || !AdminUserService.checkEmail(strReceipientEmail))) { strError = I18nService.getLocalizedString(MESSAGE_ERROR_WRONG_SENDER_EMAIL, request.getLocale()); } } // We get the resource from its resource service IExtendableResourceService resourceService = null; List<IExtendableResourceService> listExtendableResourceService = SpringContextService .getBeansOfType(IExtendableResourceService.class); for (IExtendableResourceService extendableResourceService : listExtendableResourceService) { if (extendableResourceService.isInvoked(strExtendableResourceType)) { resourceService = extendableResourceService; resource = extendableResourceService.getResource(strIdExtendableResource, strExtendableResourceType); } } if ((resourceService == null) || (resource == null)) { SiteMessageService.setMessage(request, MESSAGE_NO_RESOURCE_FOUND, SiteMessage.TYPE_ERROR); throw new SiteMessageException(); } String strResourceUrl = resourceService.getResourceUrl(strIdExtendableResource, strExtendableResourceType); Map<String, Object> model = new HashMap<String, Object>(); model.put(MARK_RESOURCE, resource); model.put(MARK_RESOURCE_URL, strResourceUrl); model.put(Markers.BASE_URL, AppPathService.getBaseUrl(request)); if ((strSend != null) && (strError == null)) { Map<String, Object> mailModel = new HashMap<String, Object>(); mailModel.put(Markers.BASE_URL, AppPathService.getBaseUrl(request)); mailModel.put(MARK_RESOURCE, resource); mailModel.put(PARAMETER_SENDER_EMAIL, strSenderEmail); mailModel.put(PARAMETER_SENDER_NAME, strSenderName); mailModel.put(PARAMETER_SENDER_FIRST_NAME, strSenderFirstName); mailModel.put(Parameters.EMAIL, strReceipientEmail); mailModel.put(PARAMETER_CONTENT, EditorBbcodeService.getInstance().parse(strContent)); mailModel.put(MARK_RESOURCE_URL, resourceService.getResourceUrl(strIdExtendableResource, strExtendableResourceType)); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_EMAIL_SEND_RESOURCE, request.getLocale(), mailModel); MailService.sendMailHtml(strReceipientEmail, strSenderFirstName + CONSTANT_SPACE + strSenderName, strSenderEmail, resource.getExtendableResourceName(), template.getHtml()); model.put(MARK_SUCCESS, MARK_SUCCESS); } else { model.put(PARAMETER_SENDER_EMAIL, strSenderEmail); model.put(PARAMETER_SENDER_NAME, strSenderName); model.put(PARAMETER_SENDER_FIRST_NAME, strSenderFirstName); model.put(Parameters.EMAIL, strReceipientEmail); model.put(PARAMETER_CONTENT, strContent); model.put(MARK_ERROR, strError); } model.put(Markers.PAGE_MAIN_MENU, StringUtils.EMPTY); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_SEND_RESOURCE, request.getLocale(), model); return template.getHtml(); }
From source file:com.ofbizcn.securityext.login.LoginEvents.java
public static String storeLogin(HttpServletRequest request, HttpServletResponse response) { String responseString = LoginWorker.login(request, response); if (!"success".equals(responseString)) { return responseString; }/*ww w . ja v a2s . c o m*/ if ("Y".equals(request.getParameter("rememberMe"))) { setUsername(request, response); } // if we logged in okay, do the check store customer role return "";//ProductEvents.checkStoreCustomerRole(request, response); }
From source file:com.attribyte.essem.util.Util.java
/** * Gets an integer parameter from the request with a default value. * @param request The request.//from ww w .j av a 2 s. c o m * @param name The parameter name. * @param defaultValue The default value. * @return The parameter or default value. */ public static final int getParameter(final HttpServletRequest request, final String name, final int defaultValue) { String strVal = Strings.nullToEmpty(request.getParameter(name)).trim(); if (strVal.length() == 0) return defaultValue; try { return Integer.parseInt(strVal); } catch (NumberFormatException nfe) { return defaultValue; } }
From source file:com.attribyte.essem.util.Util.java
/** * Gets a long parameter from the request with a default value. * @param request The request./*w w w . j a v a 2s . c o m*/ * @param name The parameter name. * @param defaultValue The default value. * @return The parameter or default value. */ public static final long getLongParameter(final HttpServletRequest request, final String name, final long defaultValue) { String strVal = Strings.nullToEmpty(request.getParameter(name)).trim(); if (strVal.length() == 0) return defaultValue; try { return Long.parseLong(strVal); } catch (NumberFormatException nfe) { return defaultValue; } }
From source file:com.fluidops.iwb.server.HybridSearchServlet.java
private static String determineQueryLanguage(String query, HttpServletRequest req) { String queryLanguage = req.getParameter("queryLanguage"); if (queryLanguage != null && SearchProviderFactory.getInstance().isValidQueryLanguage(queryLanguage)) return queryLanguage.toUpperCase(); queryLanguage = "DEFAULT"; int index;/*from w w w . ja v a2 s. co m*/ if ((index = query.indexOf(':')) != -1) { String tmp = query.substring(0, index); if (SearchProviderFactory.getInstance().getValidQueryLanguages().contains(tmp.toUpperCase())) queryLanguage = tmp.toUpperCase(); } return queryLanguage; }
From source file:org.wuspba.ctams.ui.server.DataUtils.java
protected static CTAMSDocument getBandRegistration(HttpServletRequest request) { BandRegistration registration = new BandRegistration(); URIBuilder builder = new URIBuilder().setScheme(ServerUtils.PROTOCOL).setHost(ServerUtils.HOST) .setPort(ServerUtils.PORT).setParameter("name", request.getParameter("band")) .setPath(ServerUtils.URI + "/band"); try {/* w ww . jav a 2 s .c o m*/ String xml = ServerUtils.get(builder.build()); CTAMSDocument bands = XMLUtils.unmarshal(xml); registration.setBand(bands.getBands().get(0)); } catch (IOException ex) { LOG.error("Error finding band", ex); } catch (URISyntaxException uex) { LOG.error("Invalide URI", uex); } registration.setId(request.getParameter("id")); try { registration.setEnd(dateParser.parse(request.getParameter("end"))); } catch (ParseException ex) { LOG.error("Cannot parse date", ex); } try { Date date = dateParser.parse(request.getParameter("start")); registration.setStart(date); } catch (ParseException ex) { LOG.error("Cannot parse date", ex); } registration.setGrade(Grade.valueOf(request.getParameter("grade"))); registration.setSeason(Integer.parseInt(request.getParameter("season"))); CTAMSDocument doc = new CTAMSDocument(); doc.getBandRegistrations().add(registration); return doc; }
From source file:org.wuspba.ctams.ui.server.DataUtils.java
protected static CTAMSDocument getSoloRegistration(HttpServletRequest request) { SoloRegistration registration = new SoloRegistration(); URIBuilder builder = new URIBuilder().setScheme(ServerUtils.PROTOCOL).setHost(ServerUtils.HOST) .setPort(ServerUtils.PORT).setParameter("firstname", request.getParameter("firstName")) .setParameter("lastname", request.getParameter("lastName")).setPath(ServerUtils.URI + "/person"); try {// w w w .j av a 2 s. c o m String xml = ServerUtils.get(builder.build()); CTAMSDocument people = XMLUtils.unmarshal(xml); registration.setPerson(people.getPeople().get(0)); } catch (IOException ex) { LOG.error("Error finding band", ex); } catch (URISyntaxException uex) { LOG.error("Invalide URI", uex); } registration.setId(request.getParameter("id")); try { registration.setEnd(dateParser.parse(request.getParameter("end"))); } catch (ParseException ex) { LOG.error("Cannot parse date", ex); } try { Date date = dateParser.parse(request.getParameter("start")); registration.setStart(date); } catch (ParseException ex) { LOG.error("Cannot parse date", ex); } registration.setGrade(Grade.valueOf(request.getParameter("grade"))); registration.setSeason(Integer.parseInt(request.getParameter("season"))); registration.setNumber(request.getParameter("number")); registration.setType(Instrument.valueOf(request.getParameter("instrument"))); CTAMSDocument doc = new CTAMSDocument(); doc.getSoloRegistrations().add(registration); return doc; }