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:com.gtwm.pb.servlets.ServletUtilMethods.java
public static BaseReportInfo getReportForRequest(SessionDataInfo sessionData, HttpServletRequest request, DatabaseInfo databaseDefn, boolean defaultToSessionReport) throws MissingParametersException, ObjectNotFoundException, DisallowedException { BaseReportInfo report = null;// w w w. ja va 2s . co m String internalReportName = request.getParameter("internalreportname"); if ((internalReportName == null) && (defaultToSessionReport)) { report = sessionData.getReport(); if (report == null) { throw new ObjectNotFoundException( "There is no report in the session - perhaps the session has timed out"); } } else if (internalReportName == null) { throw new MissingParametersException("'internalreportname' parameter needed in request"); } else { String internalTableName = request.getParameter("internaltablename"); TableInfo table = null; if (internalTableName != null) { table = databaseDefn.getTable(request, internalTableName); } else { table = databaseDefn.findTableContainingReport(request, internalReportName); } report = table.getReport(internalReportName); } return report; }
From source file:com.stratelia.silverpeas.pdcPeas.servlets.PdcSearchRequestRouterHelper.java
public static QueryParameters saveFavoriteRequestAndSetPdcInfo(PdcSearchSessionController pdcSC, HttpServletRequest request) throws Exception { String favoriteRequestId = request.getParameter("iCenterId"); return saveFavoriteRequestAndSetPdcInfo(pdcSC, request, favoriteRequestId); }
From source file:common.web.controller.CommonActions.java
/** * executes an update, serves as a template method that incapsulates common logic for update action * @param service/*from ww w .jav a2 s .c o m*/ * @param config * @param val * @param req * @return false if id cannot be converted to long or where is no command with an appropriate id */ public static <T> boolean doUpdate(IUpdateService<T, Long> service, IControllerConfig config, ABindValidator val, HttpServletRequest req) { Long id = RequestUtils.getLongParam(req, "id"); T command = null; if (id != null) { command = service.getUpdateBean(id); } if (id == null || command == null) { common.CommonAttributes.addErrorMessage("form_errors", req); return false; } String action = req.getParameter(ControllerConfig.ACTION_PARAM_NAME); RequestUtils.copyRequestAttributesFromMap(req, service.initUpdate()); if ("update".equals(action)) { /** bind command */ BindingResult res = val.bindAndValidate(command, req); if (res.hasErrors()) { //m.putAll(res.getModel()); req.setAttribute(res.MODEL_KEY_PREFIX + config.getContentDataAttribute(), res); req.setAttribute(config.getContentDataAttribute(), command); common.CommonAttributes.addErrorMessage("form_errors", req); } else { service.update(command); req.setAttribute(config.getContentDataAttribute(), command); common.CommonAttributes.addHelpMessage("operation_succeed", req); } } else { req.setAttribute(config.getContentDataAttribute(), command); } return true; }
From source file:net.mindengine.oculus.frontend.service.customization.CustomizationUtils.java
/** * Fetches the unit customization value from the post request * /*from w w w. ja va 2 s. c o m*/ * @param request * @param customization * @return */ public static UnitCustomizationValue getUnitCustomizationValue(Long unitId, HttpServletRequest request, Customization customization, List<CustomizationPossibleValue> possibleValues) { if (customization.getType().equals(Customization.TYPE_CHECKBOX)) { String value = request.getParameter("customization_" + customization.getId()); if (value == null) value = "false"; if (value.equals("on")) value = "true"; return new UnitCustomizationValue(unitId, customization.getId(), value); } else if (customization.getType().equals(Customization.TYPE_CHECKLIST)) { StringBuffer value = new StringBuffer(); /* * The possible value ids are represented in the following format: * (34234)(34235)(5345)(5345) Important that each id should be * placed in the brackets */ for (CustomizationPossibleValue cpv : possibleValues) { if ("on".equals( request.getParameter("customization_" + customization.getId() + "_pv_" + cpv.getId()))) { value.append("("); value.append(cpv.getId()); value.append(")"); } } return new UnitCustomizationValue(unitId, customization.getId(), value.toString()); } else { String value = request.getParameter("customization_" + customization.getId()); if (value == null) value = ""; return new UnitCustomizationValue(unitId, customization.getId(), value); } }
From source file:com.glaf.base.utils.ParamUtil.java
/** * ?/* w ww .j ava2 s .c om*/ * * @param request * HttpServletRequest request * @param param * String ? * @param defaultValue * String ? * @return String ? */ public static String getParameter(HttpServletRequest request, String param, String defaultValue) { String value = request.getParameter(param); if (value == null || value.length() == 0) { if (defaultValue != null) value = defaultValue; else value = ""; } else { value = value.trim(); } return value; }
From source file:org.carewebframework.security.spring.DesktopSecurityContextRepository.java
/** * Given a servlet request, returns Spring security context object. * /*from w w w. j a v a 2s. c o m*/ * @param request HttpServletRequest * @return SecurityContext The Spring security context. First looks for the desktop-based * security context. If not found, then looks for a session-based security context. This * call will convert a session-based security context to desktop-based if a desktop * identifier is found in the request object, a desktop-based security context does not * exist, and a session-based security context does exist. * @throws IllegalStateException if session is invalidated */ public static SecurityContext getSecurityContext(HttpServletRequest request) { final HttpSession session = request.getSession(false); boolean ignore = "rmDesktop".equals(request.getParameter("cmd_0")); return ignore || session == null ? SecurityContextHolder.createEmptyContext() : getSecurityContext(session, request.getParameter("dtid")); }
From source file:edu.lafayette.metadb.web.metadata.UpdateAdminDescMetadata.java
public static JSONObject whitelist(String id_string, String projname, String type, int itemNumber, HttpServletRequest request) throws JSONException { JSONObject result = new JSONObject(); int id = Integer.parseInt(id_string); AdminDescItem item = AdminDescItemsDAO.getItem(projname, type, id, itemNumber); boolean validated = true; String newData = request.getParameter(id_string); String error_message = "Cannot update metadata"; if (newData != null) { if (item.isReadableDate()) { validated &= isValidDisplayDate(newData); error_message = "Display date is not valid"; } else if (item.isSearchableDate()) { validated &= isValidSearchDate(newData); error_message = "Search date is not valid"; } else if (item.isControlled()) { newData = ""; String[] new_terms = request.getParameterValues(id_string); if (item.isAdditions()) { addTerm(item, new_terms); }// ww w .j ava 2 s . c om /** * Important: controlled vocab terms are sorted before updating the database * To disable sorting, use another data structure since Set does not preserve order, * only maintains uniqueness of elements. */ Set<String> vocabList = ControlledVocabDAO.getControlledVocab(item.getVocab()); Collection<String> updatedVocab; if (item.isSorted()) //if sorted, use TreeSet updatedVocab = new TreeSet<String>(); else //otherwise, use LinkedList updatedVocab = new LinkedList<String>(); for (int i = 0; i < new_terms.length; i++) { String term = StringUtils.strip(new_terms[i]); //MetaDbHelper.note(term); if (!term.equals("") && !vocabList.add(term)) updatedVocab.add(term); } int i = 0; Iterator<String> itr = updatedVocab.iterator(); while (itr.hasNext()) { newData += itr.next(); if (i != updatedVocab.size() - 1) newData += ";"; i++; } } if (validated) { result.put("success", true); result.put("data", newData); } else { result.put("success", false); result.put("id", id); result.put("element", item.getElement()); result.put("label", item.getLabel()); result.put("message", error_message); } } return result; }
From source file:info.magnolia.cms.util.RequestFormUtil.java
/** * returns the value found in the form or the request * @param request/* w w w. j a va2s . c o m*/ * @param form * @param name * @return */ public static String getParameter(HttpServletRequest request, MultipartForm from, String name) { String param = null; if (from != null) { param = from.getParameter(name); } if (param == null) { if (request.getMethod().equals("GET")) { param = getURLParameterDecoded(request, name, "UTF8"); } else { param = request.getParameter(name); } } return param; }
From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java
protected static void leerMultiplesConvocatorias(HttpServletRequest request, HttpServletResponse response) throws IOException { ArrayList<ConvocatoriaEntity> convocatorias = new ArrayList<>(); convocatorias = CtrlUsuario.leerMultiplesConvocatorias(Integer.parseInt(request.getParameter("1")), Integer.parseInt(request.getParameter("2"))); // tamao y posicin response.setContentType("application/json;charset=UTF-8"); PrintWriter out = response.getWriter(); JSONArray list1 = new JSONArray(); for (ConvocatoriaEntity convocatoria : convocatorias) { JSONObject obj = new JSONObject(); obj.put("id", convocatoria.getIdConvocatoria()); obj.put("titulo", convocatoria.getNombre()); list1.add(obj);/*w ww . ja v a2 s. c o m*/ } out.print(list1); }
From source file:com.healthcit.analytics.utils.CAHopeDataSourceUtils.java
/** * Validates a Query// w w w . j a v a 2s. co m */ public static void validateQuery(Query query, HttpServletRequest request) throws QueryInvalidException { // if the user specified a SELECT statement, // then the request parameter "orderedColumnNames" is required if (query.getSelection() != null && StringUtils.isBlank(request.getParameter(Constants.ORDERED_COLUMN_NAMES))) { throw new QueryInvalidException( "ERROR: The request parameter \"orderedColumnNames\" is required when you specify a SELECT in the query."); } }