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:de.knurt.fam.template.util.ContactDetailsRequestHandler.java
/** * return the value with given key in given request, if it is set and not * empty.//from www. j a v a2 s. c o m * * @param rq * request got * @param key * interested in * @return the value with given key in given request, if it is set and not * empty. */ public static String getValue(HttpServletRequest rq, String key) { String result = rq.getParameter(key) == null ? null : rq.getParameter(key).trim(); return result == null || result.isEmpty() ? null : result; }
From source file:com.mobileman.projecth.web.util.ViewState.java
public static void copyViewState(HttpServletRequest request, Model model) { Map<String, String> postValues = new HashMap<String, String>(); model.addAttribute("postValues", postValues); for (@SuppressWarnings("unchecked") Enumeration<String> e = request.getParameterNames(); e.hasMoreElements();) { String name = e.nextElement(); String value = request.getParameter(name); postValues.put(name, value);// www .j a v a 2s .c o m //remove later, use only postValues if (!name.startsWith("select") && !name.contains("password")) { model.addAttribute(name, value); } } }
From source file:com.silverpeas.util.i18n.I18NHelper.java
public static String[] getLanguageAndTranslationId(HttpServletRequest request) { String param = request.getParameter(HTMLSelectObjectName); return getLanguageAndTranslationId(param); }
From source file:com.ai.smart.common.helper.util.RequestUtils.java
/** * ?QueryString?URLDecoderUTF-8??post??//from w w w . ja v a 2 s . co m * HttpServletRequest#getParameter? * * @param request web * @param name ??? * @return */ public static String getQueryParam(HttpServletRequest request, String name) { if (StringUtils.isBlank(name)) { return null; } if (request.getMethod().equalsIgnoreCase(POST)) { return request.getParameter(name); } String s = request.getQueryString(); if (StringUtils.isBlank(s)) { return null; } try { s = URLDecoder.decode(s, UTF8); } catch (UnsupportedEncodingException e) { log.error("encoding " + UTF8 + " not support?", e); } String[] values = parseQueryString(s).get(name); if (values != null && values.length > 0) { return values[values.length - 1]; } else { return null; } }
From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Admin.CUDEventos.java
protected static void iniciarWSC(HttpServletRequest request, HttpServletResponse response) throws IOException { ArrayList<UsuarioEntity> usuarios = CtrlAdmin.iniciarWSC(Integer.parseInt(request.getParameter("1")), //id evento Integer.parseInt(request.getParameter("2")), //tamao tabla Integer.parseInt(request.getParameter("3"))//pagina ); // parameter 1: documentoDocente param2: idTaller response.setContentType("application/json;charset=UTF-8"); PrintWriter out = response.getWriter(); JSONArray list1 = new JSONArray(); for (UsuarioEntity usuario : usuarios) { JSONObject obj = new JSONObject(); obj.put("id", usuario.getIdUsuario()); obj.put("titulo", usuario.getNombres() + " " + usuario.getApellidos()); list1.add(obj);//from w w w . j a v a2 s .c o m } out.print(list1); }
From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Admin.CUDEventos.java
protected static void eliminarConvocatoria(HttpServletRequest request, HttpServletResponse response) throws IOException { ArrayList r = CtrlAdmin.eliminarConvocatoria(Integer.parseInt(request.getParameter("1"))); // id response.setContentType("application/json;charset=UTF-8"); PrintWriter out = response.getWriter(); if (r.get(0) == "error") { JSONObject obj = new JSONObject(); obj.put("isError", true); obj.put("errorDescrip", r.get(1)); out.print(obj);//ww w. j a va 2 s . c o m } else if (r.get(0) == "isExitoso") { JSONObject obj = new JSONObject(); obj.put("Exitoso", true); out.print(obj); } else Util.errordeRespuesta(r, out); }
From source file:com.runwaysdk.controller.ErrorUtility.java
public static void prepareMessages(HttpServletRequest req) { String errorMessage = req.getParameter(ErrorUtility.ERROR_MESSAGE); String errorMessageArray = req.getParameter(ErrorUtility.ERROR_MESSAGE_ARRAY); String compressedMessage = req.getParameter(ErrorUtility.MESSAGE_ARRAY); if (errorMessage != null) { req.setAttribute(ERROR_MESSAGE, errorMessage); }/* www .jav a 2s.com*/ if (errorMessageArray != null) { String[] array = errorMessageArray.split("\\n"); req.setAttribute(ERROR_MESSAGE_ARRAY, array); } if (compressedMessage != null) { String message = ErrorUtility.decompress(compressedMessage); String[] array = message.split("\\n"); req.setAttribute(MESSAGE_ARRAY, array); } }
From source file:common.web.controller.CommonActions.java
/** * executes an update, serves as a template method that incapsulates common logic for delete action * @param service// w w w. j a v a 2 s .c o m * @param req * @return false if id cannot be converted to long */ public static boolean doDelete(IDeleteService<Long> service, HttpServletRequest req) { Long id = RequestUtils.getLongParam(req, "id"); if (id == null) { common.CommonAttributes.addErrorMessage("form_errors", req); return false; } String action = req.getParameter(ControllerConfig.ACTION_PARAM_NAME); if ("delete".equals(action)) { if (service.deleteById(id) > 0) { common.CommonAttributes.addHelpMessage("operation_succeed", req); //logger.fine("not hasErrors"); } else { common.CommonAttributes.addErrorMessage("operation_fail", req); //logger.fine("hasErrors"); } } return true; }
From source file:io.lavagna.web.security.CSFRFilter.java
private static ImmutablePair<Boolean, ImmutablePair<Integer, String>> checkCSRF(HttpServletRequest request) throws IOException { String expectedToken = (String) request.getSession().getAttribute(CSRFToken.CSRF_TOKEN); String token = request.getHeader(CSRF_TOKEN_HEADER); if (token == null) { token = request.getParameter(CSRF_FORM_PARAMETER); }/*from ww w . ja v a 2 s . c o m*/ if (token == null) { return of(false, of(HttpServletResponse.SC_FORBIDDEN, "missing token in header or parameter")); } if (expectedToken == null) { return of(false, of(HttpServletResponse.SC_FORBIDDEN, "missing token from session")); } if (!safeArrayEquals(token.getBytes("UTF-8"), expectedToken.getBytes("UTF-8"))) { return of(false, of(HttpServletResponse.SC_FORBIDDEN, "token is not equal to expected")); } return of(true, null); }
From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Admin.CUDEventos.java
protected static void actualizarTaller(HttpServletRequest request, HttpServletResponse response) throws IOException { ArrayList r = CtrlAdmin.actualizarTaller(Integer.parseInt(request.getParameter("0")), // id request.getParameter("1"), // nombre request.getParameter("2"), // descripcin request.getParameter("3"), // fin registro (Fecha hasta donde est permitido registrarse) request.getParameter("4"), // inicio del taller Integer.parseInt(request.getParameter("5")), // costo Integer.parseInt(request.getParameter("6")) // cupos );/*from w w w.ja v a 2s. co m*/ response.setContentType("application/json;charset=UTF-8"); PrintWriter out = response.getWriter(); if (r.get(0) == "error") { JSONObject obj = new JSONObject(); obj.put("isError", true); obj.put("errorDescrip", r.get(1)); out.print(obj); } else if (r.get(0) == "isExitoso") { JSONObject obj = new JSONObject(); obj.put("Exitoso", true); out.print(obj); } else Util.errordeRespuesta(r, out); }