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.ixcode.framework.model.lookup.LookupHandler.java
public static boolean isLookupSubmission(HttpServletRequest request) { String command = request.getParameter(PARAM_LOOKUP_COMMAND); return (command != null) && (command.length() > 0); }
From source file:net.duckling.ddl.web.interceptor.access.FetchCodeInterceptor.java
private static List<Integer> getCurrentRid(HttpServletRequest request) { List<Integer> result = new ArrayList<Integer>(); String r = request.getParameter("rid"); int rid = 0;//from www .ja v a 2 s . c om if (StringUtils.isEmpty(r)) { String path = request.getParameter("path"); if (!StringUtils.isEmpty(path)) { String[] s = path.split("/"); try { rid = Integer.parseInt(s[s.length - 1]); result.add(rid); } catch (Exception e) { } } else { String[] rids = request.getParameterValues("rids"); if (rids != null) { for (String ri : rids) { try { rid = Integer.parseInt(ri); result.add(rid); } catch (Exception e) { } } } } } else { rid = Integer.parseInt(r); result.add(rid); } return result; }
From source file:jease.site.Streams.java
/** * Write given file to response./*from w w w .j a va2s . co m*/ * * If the given content type denotes a browser supported image, the image * will be automatically scaled if either "scale" is present as request * paramter or JEASE_IMAGE_LIMIT is set in Registry. */ public static void write(HttpServletRequest request, HttpServletResponse response, File file, String contentType) throws IOException { if (Images.isBrowserCompatible(contentType)) { int scale = NumberUtils.toInt(request.getParameter("scale")); if (scale > 0) { java.io.File scaledImage = Images.scale(file, scale); scaledImage.deleteOnExit(); response.setContentType(contentType); response.setContentLength((int) scaledImage.length()); Files.copy(scaledImage.toPath(), response.getOutputStream()); return; } int limit = NumberUtils.toInt(Registry.getParameter(Names.JEASE_IMAGE_LIMIT)); if (limit > 0) { java.io.File scaledImage = Images.limit(file, limit); scaledImage.deleteOnExit(); response.setContentType(contentType); response.setContentLength((int) scaledImage.length()); Files.copy(scaledImage.toPath(), response.getOutputStream()); return; } } response.setContentType(contentType); response.setContentLength((int) file.length()); Files.copy(file.toPath(), response.getOutputStream()); }
From source file:net.cristcost.study.services.ServiceTestUtil.java
private static void wait(PrintWriter writer, HttpServletRequest request, AuthenticationManager authenticationManager) { if (request.getParameter("entropy") != null) { try {//from w w w . j av a 2 s . c o m int waitTime = Integer.parseInt(request.getParameter("wait")); Thread.sleep(waitTime); writer.println("* Waiting for creating Thread entropy: " + waitTime + " ms"); } catch (NumberFormatException | InterruptedException e) { writer.println("* Exception while creating Thread entropy: " + e.getMessage()); } writer.println(); } }
From source file:adalid.jaas.google.GoogleRecaptcha.java
private static String getRequestParameter(String key) { if (key == null) { return null; }/*from ww w . ja va 2s. c om*/ Object request; try { request = PolicyContext.getContext(HttpServletRequest.class.getName()); } catch (PolicyContextException ex) { logger.log(Level.SEVERE, ex.toString(), ex); return null; } if (request instanceof HttpServletRequest) { HttpServletRequest httpServletRequest = (HttpServletRequest) request; String parameter = httpServletRequest.getParameter(key); logger.log(TRACE, "{0}: {1}", new Object[] { key, parameter }); return parameter; } logger.log(TRACE, "HTTP Servlet Request: {0}", request); return null; }
From source file:com.formkiq.core.webflow.FlowManager.java
/** * Get Event Id./*from w w w.j a v a2 s. co m*/ * @param request {@link HttpServletRequest} * @return int */ public static int getEventId(final HttpServletRequest request) { Pair<String, Integer> webflowkey = getExecutionSessionKey(request.getParameter(PARAMETER_EXECUTION)); Integer eventId = webflowkey.getRight(); return eventId != null ? eventId.intValue() : 1; }
From source file:com.formkiq.core.webflow.FlowManager.java
/** * Finds the current {@link WebFlow} if one exists. * @param req {@link HttpServletRequest} * @return {@link WebFlow}// w w w . jav a 2s .c om */ private static WebFlow getCurrentWebFlow(final HttpServletRequest req) { Pair<String, Integer> webflowkey = getExecutionSessionKey(req.getParameter(PARAMETER_EXECUTION)); String sessionKey = webflowkey.getLeft(); if (StringUtils.hasText(sessionKey)) { Object obj = req.getSession().getAttribute(sessionKey); if (obj instanceof WebFlow) { WebFlow wf = (WebFlow) obj; return wf; } } throw new FlowNotFoundException(); }
From source file:io.lavagna.web.helper.UserSession.java
public static void setUser(int userId, boolean isUserAnonymous, HttpServletRequest req, HttpServletResponse resp, UserRepository userRepository) { boolean rememberMe = "true".equals(req.getParameter("rememberMe")) || "true".equals(req.getAttribute("rememberMe")); setUser(userId, isUserAnonymous, req, resp, userRepository, rememberMe); }
From source file:org.ow2.chameleon.fuchsia.push.base.hub.dto.ContentNotification.java
private static void validateRequest(HttpServletRequest request) throws InvalidContentNotification { if (!MediaType.APPLICATION_FORM_URLENCODED.equals(request.getContentType())) { throw new InvalidContentNotification("Invalid content type"); }/* w w w . j a v a2 s . c o m*/ if (request.getParameter(HUB_MODE) == null) { throw new InvalidContentNotification("No " + HUB_MODE + " provided"); } if (request.getParameter(HUB_URL) == null) { throw new InvalidContentNotification("No " + HUB_URL + " provided"); } }
From source file:org.openmrs.module.logmanager.web.util.WebUtils.java
/** * Gets an int parameter from the request that is being "remembered" in the session * @param request the http request// ww w.j a v a 2 s . co m * @param name the name of the parameter * @param def the default value of the parameter * @param sessionPrefix the prefix to generate session attribute from parameter name * @return the parameter value */ public static int getSessionedIntParameter(HttpServletRequest request, String name, int def, String sessionPrefix) { HttpSession session = request.getSession(); int val = def; // If specified in request, read that and store in session if (request.getParameter(name) != null) { val = ServletRequestUtils.getIntParameter(request, name, def); session.setAttribute(sessionPrefix + name, val); } // Otherwise look for a matching attribute in the session else { Integer sessionVal = (Integer) session.getAttribute(sessionPrefix + name); if (sessionVal != null) val = sessionVal; } return val; }