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:net.ontopia.topicmaps.webed.impl.utils.TagUtils.java
public static FormTag getCurrentFormTag(ServletRequest request) { return (FormTag) request.getAttribute("OKS_FORM"); }
From source file:net.ontopia.topicmaps.webed.impl.utils.TagUtils.java
/** * INTERNAL: Returns true if the form is read-only. * @param request The current request object * @return a boolean object indicating whether the form is read-only or not *///ww w. j a va2 s . c o m public static boolean isFormReadOnly(ServletRequest request) { Boolean value = (Boolean) request.getAttribute(Constants.OKS_FORM_READONLY); return value != null && value.booleanValue(); }
From source file:org.opencms.xml.page.CmsXmlPageFactory.java
/** * Factory method to unmarshal (read) a XML document instance from * a filename in the VFS, using the request attributes as cache.<p> * // w w w .j av a 2 s .c om * @param cms the current OpenCms user context * @param filename the filename of the resource to unmarshal * @param req the current request * * @return the unmarshaled XML document, or <code>null</code> if the given resource was not of type {@link I_CmsXmlDocument} * * @throws CmsException in something goes wrong */ public static I_CmsXmlDocument unmarshal(CmsObject cms, String filename, ServletRequest req) throws CmsException { // add site root to filename String rootPath = cms.getRequestContext().addSiteRoot(filename); // try to get the requested page form the current request attributes I_CmsXmlDocument doc = (I_CmsXmlDocument) req.getAttribute(rootPath); if (doc != null) { return doc; } // always use "ignore expiration" filter, date validity must be checked before calling this if required CmsFile file = cms.readFile(filename, CmsResourceFilter.IGNORE_EXPIRATION); if (CmsResourceTypeXmlPage.isXmlPage(file)) { // file is of type XML page doc = CmsXmlPageFactory.unmarshal(cms, file); } else if (CmsResourceTypeXmlContent.isXmlContent(file)) { // file is of type XML content doc = CmsXmlContentFactory.unmarshal(cms, file); } else { // sanity check: file type not an A_CmsXmlDocument throw new CmsXmlException(Messages.get().container(Messages.ERR_XML_PAGE_FACT_NO_XML_DOCUMENT_1, file)); } // store the page that was read as request attribute for future read requests req.setAttribute(rootPath, doc); return doc; }
From source file:no.sesat.search.http.filters.SiteLocatorFilter.java
static String getRequestId(final ServletRequest servletRequest) { if (null == servletRequest.getAttribute("UNIQUE_ID")) { servletRequest.setAttribute("UNIQUE_ID", UUID.randomUUID().toString()); }/*from w w w . ja va 2s . c om*/ return (String) servletRequest.getAttribute("UNIQUE_ID"); }
From source file:org.alfresco.web.app.portlet.AlfrescoFacesPortlet.java
/** * Initializes a new faces context using the portlet objects from a 'wrapped' servlet request. * //from w w w . j a va 2 s . co m * @param request * the servlet request * @return the faces context */ public static FacesContext getFacesContext(ServletRequest request) { PortletRequest portletReq = (PortletRequest) request.getAttribute("javax.portlet.request"); PortletResponse portletRes = (PortletResponse) request.getAttribute("javax.portlet.response"); PortletConfig portletConfig = (PortletConfig) request.getAttribute("javax.portlet.config"); return FacesHelper.getFacesContext(portletReq, portletRes, portletConfig.getPortletContext()); }
From source file:org.alfresco.web.app.portlet.AlfrescoFacesPortlet.java
/** * Creates an action url from the given request. * //ww w .j a v a2s . co m * @param request * the request * @return the action url */ public static String getActionURL(ServletRequest request) { RenderResponse renderResp = (RenderResponse) request.getAttribute("javax.portlet.response"); if (renderResp == null) { throw new IllegalStateException( "RenderResponse object is null. The web application is not executing within a portal server!"); } return renderResp.createActionURL().toString(); }
From source file:org.alfresco.web.app.portlet.AlfrescoFacesPortlet.java
/** * Gets the error bean from a request/* ww w. ja v a 2 s . c o m*/ * * @param request * the request * @return the error bean */ public static ErrorBean getErrorBean(ServletRequest request) { PortletRequest portletReq = (PortletRequest) request.getAttribute("javax.portlet.request"); if (portletReq != null) { PortletSession session = portletReq.getPortletSession(false); if (session != null) { return (ErrorBean) session.getAttribute(ErrorBean.ERROR_BEAN_NAME); } } return null; }
From source file:org.opencms.flex.CmsFlexController.java
/** * Checks if the provided request is running in OpenCms.<p> * * @param req the current request/*from w w w .j a va 2 s . com*/ * * @return <code>true</code> if the request is running in OpenCms, <code>false</code> otherwise */ public static boolean isCmsRequest(ServletRequest req) { return ((req != null) && (req.getAttribute(ATTRIBUTE_NAME) != null)); }
From source file:org.opencms.flex.CmsFlexController.java
/** * Returns the controller from the given request, or <code>null</code> if the * request is not running inside OpenCms.<p> * /*from w w w. ja v a 2 s.com*/ * @param req the request to get the controller from * * @return the controller from the given request, or <code>null</code> if the request is not running inside OpenCms */ public static CmsFlexController getController(ServletRequest req) { return (CmsFlexController) req.getAttribute(ATTRIBUTE_NAME); }
From source file:org.jruby.rack.mock.WebUtils.java
/** * Determine whether the given request is an include request, * that is, not a top-level HTTP request coming in from the outside. * <p>Checks the presence of the "javax.servlet.include.request_uri" * request attribute. Could check any request attribute that is only * present in an include request./*from w w w . ja v a2 s. c o m*/ * @param request current servlet request * @return whether the given request is an include request */ public static boolean isIncludeRequest(ServletRequest request) { return (request.getAttribute(INCLUDE_REQUEST_URI_ATTRIBUTE) != null); }