List of usage examples for javax.servlet.http HttpServletRequest getAttribute
public Object getAttribute(String name);
Object
, or null
if no attribute of the given name exists. From source file:de.otto.mongodb.profiler.web.DefaultController.java
private static Throwable throwableFrom(HttpServletRequest request) { final Object obj = request.getAttribute("javax.servlet.error.exception"); return obj != null && obj instanceof Throwable ? ((Throwable) obj) : null; }
From source file:com.bstek.dorado.view.resolver.PageOutputUtils.java
public static View getView(HttpServletRequest request) { return (View) request.getAttribute(View.class.getName()); }
From source file:cn.edu.zjnu.acm.judge.config.JudgeHandlerInterceptor.java
private static String getString(String attributeName, Function<HttpServletRequest, String> supplier, HttpServletRequest request) { String value = (String) request.getAttribute(attributeName); if (value != null) { return value; }/* www .j a v a 2s . c o m*/ return supplier.apply(request); }
From source file:cn.edu.zjnu.acm.judge.exception.GlobalExceptionHandler.java
public static String unauthorized(HttpServletRequest request) throws IOException { String url = (String) request.getAttribute(JudgeHandlerInterceptor.BACK_URL_ATTRIBUTE_NAME); return url == null ? "redirect:/login" : "redirect:/login?url=" + URLEncoder.encode(url, "UTF-8"); }
From source file:com.enonic.cms.web.portal.instanttrace.InstantTraceRequestInspector.java
public static String getOriginalUrl(final HttpServletRequest request) { String originalUrl = (String) request.getAttribute("itrace.originalUrl"); if (StringUtils.isBlank(originalUrl)) { return getParameterOriginalUrl(request); }// w ww . j a v a2 s . c om return originalUrl; }
From source file:edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.java
public static EditMode getEditMode(HttpServletRequest request, String relatedPropertyUri) { Individual obj = (Individual) request.getAttribute("object"); return getEditMode(request, obj, relatedPropertyUri); }
From source file:ru.org.linux.csrf.CSRFProtectionService.java
/** * Check if user is authorized for request * @param request/* w ww. j a v a2s . com*/ * @return true when ok, false when not authorized */ public static boolean checkCSRF(HttpServletRequest request) { String cookieValue = (String) request.getAttribute(CSRF_ATTRIBUTE); if (Strings.isNullOrEmpty(cookieValue)) { logger.info("Missing CSRF cookie"); return false; } String inputValue = request.getParameter(CSRF_INPUT_NAME); if (Strings.isNullOrEmpty(inputValue)) { logger.info("Missing CSRF input"); return false; } boolean r = inputValue.trim().equals(cookieValue.trim()); if (!r) { logger.info(String.format("Flood protection (CSRF cookie differs: cookie=%s param=%s) ip=%s url=%s", cookieValue, inputValue, request.getRemoteAddr(), request.getRequestURI())); } return r; }
From source file:com.netflix.genie.web.controllers.ControllerUtils.java
/** * Get the remaining path from a given request. e.g. if the request went to a method with the matching pattern of * /api/v3/jobs/{id}/output/** and the request was /api/v3/jobs/{id}/output/blah.txt the return value of this * method would be blah.txt.// www. j ava2 s . c o m * * @param request The http servlet request. * @return The remaining path */ public static String getRemainingPath(final HttpServletRequest request) { String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE); if (path != null) { final String bestMatchPattern = (String) request .getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE); log.debug("bestMatchPattern = {}", bestMatchPattern); path = new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path); } path = path == null ? EMPTY_STRING : path; log.debug("Remaining path = {}", path); return path; }
From source file:com.bstek.dorado.view.resolver.PageOutputUtils.java
private static OutputContext getOutputContext(HttpServletRequest request, Writer writer) { OutputContext outputContext = (OutputContext) request.getAttribute(OutputContext.class.getName()); if (outputContext == null) { outputContext = new OutputContext(writer); request.setAttribute(OutputContext.class.getName(), outputContext); outputContext/*w w w . j ava 2 s . co m*/ .setShouldOutputDataTypes(WebConfigure.getBoolean("view.outputDataTypesInPageTemplate", true)); outputContext.setUsePrettyJson(Configure.getBoolean("view.outputPrettyJson")); } return outputContext; }
From source file:com.jsmartframework.web.manager.CsrfEncrypter.java
private static Cipher getEncryptCipher(HttpServletRequest request, String key) throws Exception { Cipher encryptCipher = (Cipher) request.getAttribute(REQUEST_CSRF_ENCRYPT_CIPHER); if (encryptCipher == null) { encryptCipher = Cipher.getInstance("AES"); SecretKey secretKey = new SecretKeySpec(key.getBytes("UTF8"), "AES"); encryptCipher.init(Cipher.ENCRYPT_MODE, secretKey); request.setAttribute(REQUEST_CSRF_ENCRYPT_CIPHER, encryptCipher); }// ww w .j a v a 2 s.c o m return encryptCipher; }