List of usage examples for javax.servlet ServletRequest getAttribute
public Object getAttribute(String name);
Object
, or null
if no attribute of the given name exists. From source file:org.jahia.services.render.filter.AggregateFilter.java
/** * Utility method to check if the aggregation is skipped. * @param request is the current request * @return/* w w w .j av a 2s .c om*/ */ public static boolean skipAggregation(ServletRequest request) { return BooleanUtils.isTrue((Boolean) request.getAttribute(SKIP_AGGREGATION)); }
From source file:org.apache.felix.webconsole.WebConsoleUtil.java
/** * Returns the {@link VariableResolver} for the given request. * <p>//from www. j a va2 s . c o m * If no resolver has yet be created for the requests, an instance of the * {@link DefaultVariableResolver} is created with preset properties, * placed into the request and returned. The preset properties are * <code>appRoot</code> set to the value of the * {@link WebConsoleConstants#ATTR_APP_ROOT} request attribute and * <code>pluginRoot</code> set to the value of the * {@link WebConsoleConstants#ATTR_PLUGIN_ROOT} request attribute. * <p> * <b>Note</b>: An object not implementing the {@link VariableResolver} * interface already stored as the * {@link WebConsoleConstants#ATTR_CONSOLE_VARIABLE_RESOLVER} attribute * will silently be replaced by the {@link DefaultVariableResolver} * instance. * * @param request The request whose attribute is returned (or set) * * @return The {@link VariableResolver} for the given request. */ public static VariableResolver getVariableResolver(final ServletRequest request) { final Object resolverObj = request.getAttribute(WebConsoleConstants.ATTR_CONSOLE_VARIABLE_RESOLVER); if (resolverObj instanceof VariableResolver) { return (VariableResolver) resolverObj; } final DefaultVariableResolver resolver = new DefaultVariableResolver(); // FIXME: don't we need a constant for the values below? resolver.put("appRoot", request.getAttribute(WebConsoleConstants.ATTR_APP_ROOT)); //$NON-NLS-1$ resolver.put("pluginRoot", request.getAttribute(WebConsoleConstants.ATTR_PLUGIN_ROOT)); //$NON-NLS-1$ setVariableResolver(request, resolver); return resolver; }
From source file:com.agiletec.apsadmin.system.dispatcher.Struts2ServletDispatcher.java
protected static void cleanUp(ServletRequest req) { // should we clean up yet? Integer count = (Integer) req.getAttribute(COUNTER); if (count != null && count > 0) { if (LOG.isDebugEnabled()) { LOG.debug("skipping cleanup counter=" + count); }//from w w w . j a va2s . c om return; } // always dontClean up the thread request, even if an action hasn't been executed ActionContext.setContext(null); Dispatcher.setInstance(null); }
From source file:org.echocat.jemoni.jmx.support.ServletHealth.java
@Nullable public static Duration findCurrentRequestDurationOf(@Nonnull ServletRequest request) { final Object plainStopWatch = request.getAttribute(CURRENT_REQUEST_STOP_WATCH_ATTRIBUTE_NAME); return plainStopWatch instanceof StopWatch ? ((StopWatch) plainStopWatch).getCurrentDuration() : null; }
From source file:com.ocpsoft.pretty.PrettyContext.java
/** * Return true if there is an instantiated {@link PrettyContext} contained in * the current given request object./* w w w . j av a 2s .c o m*/ */ public static boolean isInstantiated(final ServletRequest request) { Assert.notNull(request, "HttpServletRequest argument was null"); PrettyContext prettyContext = (PrettyContext) request.getAttribute(CONTEXT_REQUEST_KEY); if (prettyContext instanceof PrettyContext) { return true; } else { return false; } }
From source file:com.day.cq.wcm.foundation.forms.FormResourceEdit.java
/** * Get the list of resources to be handled by the "edit" resources form action. * @param req current request//from w w w . j a v a 2 s . c o m * @return the list of resources (or <code>null</code> if not set) */ @SuppressWarnings("unchecked") public static List<Resource> getResources(ServletRequest req) { return (List<Resource>) req.getAttribute(RESOURCES_ATTRIBUTE); }
From source file:org.opencms.jsp.CmsJspTagEditable.java
/** * Returns the current initialized instance of the direct edit provider parameters from the given page context.<p> * //from w w w . ja v a 2 s . c o m * Also removes the parameters from the given page context.<p> * * @param context the current JSP page context * * @return the current initialized instance of the direct edit provider parameters */ protected static CmsDirectEditParams getDirectEditProviderParams(PageContext context) { // get the current request ServletRequest req = context.getRequest(); // get the direct edit params from the request attributes CmsDirectEditParams result = (CmsDirectEditParams) req .getAttribute(I_CmsDirectEditProvider.ATTRIBUTE_DIRECT_EDIT_PROVIDER_PARAMS); if (result != null) { req.removeAttribute(I_CmsDirectEditProvider.ATTRIBUTE_DIRECT_EDIT_PROVIDER_PARAMS); } return result; }
From source file:org.opencms.jsp.util.CmsJspStandardContextBean.java
/** * Creates a new instance of the standard JSP context bean.<p> * //from w w w . j av a 2s . co m * To prevent multiple creations of the bean during a request, the OpenCms request context * attributes are used to cache the created VFS access utility bean.<p> * * @param req the current servlet request * * @return a new instance of the standard JSP context bean */ public static CmsJspStandardContextBean getInstance(ServletRequest req) { Object attribute = req.getAttribute(ATTRIBUTE_NAME); CmsJspStandardContextBean result; if ((attribute != null) && (attribute instanceof CmsJspStandardContextBean)) { result = (CmsJspStandardContextBean) attribute; } else { result = new CmsJspStandardContextBean(req); req.setAttribute(ATTRIBUTE_NAME, result); } return result; }
From source file:com.redhat.rhn.frontend.taglibs.list.SelectableColumnTag.java
private static void addPostScript(String script, String listName, ServletRequest request) { String key = makePostScriptKey(listName); StringBuilder test = (StringBuilder) request.getAttribute(key); if (test == null) { test = new StringBuilder(); request.setAttribute(key, test); }//from ww w . j ava 2s . c om test.append(script); }
From source file:com.redhat.rhn.frontend.taglibs.list.SelectableColumnTag.java
/** * Returns any bound post java script// ww w.java 2 s . c om * to be used by the selectable decorator * @param listName the name of the list * @param request the request param * @return the post script */ public static String getPostScript(String listName, ServletRequest request) { String key = makePostScriptKey(listName); StringBuilder test = (StringBuilder) request.getAttribute(key); if (test != null) { return test.toString(); } return ""; }