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:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java
protected static void quitarUsuarioTaller(HttpServletRequest request, HttpServletResponse response) throws IOException { ArrayList r = CtrlUsuario.abandonarTallerUsuario(Integer.parseInt(request.getParameter("1")), Integer.parseInt(request.getParameter("2"))); //1. idUsuario, 2. idEvento 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);/* w w w . j a va 2s. com*/ } 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:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java
protected static void registrarUsuarioTaller(HttpServletRequest request, HttpServletResponse response) throws IOException { ArrayList r = CtrlUsuario.registrarATallerUsuario(Integer.parseInt(request.getParameter("1")), Integer.parseInt(request.getParameter("2"))); // parameter 1: idUsuario param2: idTaller 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);//from ww w.j a v a 2 s .com } 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:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java
protected static void registrarDocenteTaller(HttpServletRequest request, HttpServletResponse response) throws IOException { ArrayList r = CtrlUsuario.registrarATallerDocente(Integer.parseInt(request.getParameter("1")), Integer.parseInt(request.getParameter("2"))); // parameter 1: idUsuarioDocente param2: idTaller 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);//w ww .j a v a 2s . c om } 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.glaf.core.util.HttpQueryUtils.java
protected static Boolean getBooleanValue(HttpServletRequest request, String name) { String value = request.getParameter(name); if (request.getAttribute(name) != null) { value = (String) request.getAttribute(name); }/* w w w . j a v a 2 s .c o m*/ if (StringUtils.equalsIgnoreCase(value, "true")) { return true; } return false; }
From source file:org.wuspba.ctams.ui.server.DataUtils.java
private static CTAMSDocument getPerson(HttpServletRequest request) { Person person = new Person(); person.setId(request.getParameter("id")); person.setTitle(request.getParameter("title")); person.setFirstName(request.getParameter("firstName")); person.setMiddleName(request.getParameter("middleName")); person.setLastName(request.getParameter("lastName")); person.setSuffix(request.getParameter("suffix")); person.setAddress(request.getParameter("address")); person.setCity(request.getParameter("city")); person.setState(request.getParameter("state")); person.setZip(request.getParameter("zip")); person.setCountry(request.getParameter("country")); person.setPhone(request.getParameter("phone")); person.setEmail(request.getParameter("email")); person.setNotes(request.getParameter("notes")); person.setBranch(Branch.valueOf(request.getParameter("branch"))); person.setLifeMember(Boolean.valueOf(request.getParameter("lifeMember"))); CTAMSDocument doc = new CTAMSDocument(); doc.getPeople().add(person);// ww w . ja v a2 s. co m return doc; }
From source file:com.gtwm.pb.servlets.ServletUtilMethods.java
public static int getRowIdForRequest(SessionDataInfo sessionData, HttpServletRequest request, DatabaseInfo databaseDefn, boolean defaultToSessionRowId) throws ObjectNotFoundException, MissingParametersException { int rowId = -1; String rowIdString = request.getParameter("rowid"); if ((rowIdString == null) && defaultToSessionRowId) { rowId = sessionData.getRowId();// w w w. ja v a2s . co m if (rowId == -1) { throw new ObjectNotFoundException("There is no row id in the session"); } } else if (rowIdString == null) { throw new MissingParametersException("'rowid' parameter needed in request"); } else { rowId = Integer.valueOf(rowIdString); } return rowId; }
From source file:com.playright.servlet.DataController.java
private static CoverageData getCoverageDateFromRequest(HttpServletRequest request) throws ServletException { CoverageData cd = new CoverageData(); try {/*from w ww . jav a 2 s .co m*/ if (!"".equalsIgnoreCase(request.getParameter("id")) && request.getParameter("id") != null) { cd.setId(Integer.parseInt(request.getParameter("id"))); } SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); java.util.Date ud = sdf.parse(request.getParameter("newsDate")); cd.setNewsDate(new java.sql.Date(ud.getTime())); cd.setNewspaper(request.getParameter("newspaper")); cd.setHeadline(request.getParameter("headline")); cd.setLanguage(request.getParameter("language")); cd.setEdition(request.getParameter("edition")); cd.setSupplement(request.getParameter("supplement")); cd.setSource(request.getParameter("source")); if (!"".equalsIgnoreCase(request.getParameter("pageNo")) && request.getParameter("pageNo") != null) { cd.setPageNo(Integer.parseInt(request.getParameter("pageNo"))); } if (!"".equalsIgnoreCase(request.getParameter("height")) && request.getParameter("height") != null) { cd.setHeight(Integer.parseInt(request.getParameter("height"))); } if (!"".equalsIgnoreCase(request.getParameter("width")) && request.getParameter("width") != null) { cd.setWidth(Integer.parseInt(request.getParameter("width"))); } if (!"".equalsIgnoreCase(request.getParameter("totalArticleSize")) && request.getParameter("totalArticleSize") != null) { cd.setTotalArticleSize(Integer.parseInt(request.getParameter("totalArticleSize"))); } if (!"".equalsIgnoreCase(request.getParameter("circulationFigure")) && request.getParameter("circulationFigure") != null) { cd.setCirculationFigure(Integer.parseInt(request.getParameter("circulationFigure"))); } if (!"".equalsIgnoreCase(request.getParameter("journalistFactor")) && request.getParameter("journalistFactor") != null) { cd.setJournalistFactor(Integer.parseInt(request.getParameter("journalistFactor"))); } if (!"".equalsIgnoreCase(request.getParameter("quantitativeAve")) && request.getParameter("quantitativeAve") != null) { cd.setQuantitativeAve(new BigDecimal(request.getParameter("quantitativeAve"))); } if (!"".equalsIgnoreCase(request.getParameter("imageExists")) && request.getParameter("imageExists") != null) { cd.setImageExists(request.getParameter("imageExists")); } Blob b = null; String fileName = ""; String contentType = ""; try { Part filePart = request.getPart("image"); InputStream fileContent = filePart.getInputStream(); byte[] bytes = IOUtils.toByteArray(fileContent); b = new SerialBlob(bytes); fileName = filePart.getSubmittedFileName(); contentType = filePart.getContentType(); } catch (IOException ex) { Logger.getLogger(DataController.class.getName()).log(Level.SEVERE, null, ex); } if (b != null && b.length() != 0) { cd.setImageBlob(b); cd.setImageFileName(fileName); cd.setImageType(contentType); } } catch (ParseException ex) { Logger.getLogger(DataController.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(DataController.class.getName()).log(Level.SEVERE, null, ex); } return cd; }
From source file:ch.systemsx.cisd.openbis.generic.client.web.server.UploadServiceServlet.java
private static List<String> extractSessionKeys(final HttpServletRequest request, final String sessionKeysNumberParameter) throws ServletException { List<String> sessionKeys = new ArrayList<String>(); for (int i = 0; i < Integer.parseInt(sessionKeysNumberParameter); i++) { String sessionKey = StringUtils.trim(request.getParameter("sessionKey_" + i)); if (StringUtils.isBlank(sessionKey)) { throw new ServletException( "No field 'sessionKey_" + i + "' could be found in the transmitted form."); }/*from www .j a v a 2 s . c o m*/ sessionKeys.add(sessionKey); } return sessionKeys; }
From source file:com.lushapp.common.web.utils.WebUtils.java
/** * ?HttpRequestParameter./*from w ww .j ava 2s . c o m*/ */ public static <T> T getParameter(HttpServletRequest request, String name) { return (T) request.getParameter(name); }
From source file:ch.rasc.downloadchart.DownloadChartServlet.java
private static <T> T readOptions(HttpServletRequest request, String requestParameter, Class<T> clazz) throws IOException, JsonParseException, JsonMappingException { String optionsString = request.getParameter(requestParameter); if (optionsString != null) { return objectMapper.readValue(optionsString, clazz); }//from ww w . j a va2 s . c o m return null; }