public int doStartTag() throws JspException { String namespace = ""; // if hstResponse is retrieved, then this servlet has been dispatched by hst component. HstResponse hstResponse = (HstResponse) pageContext.getRequest().getAttribute(ContainerConstants.HST_RESPONSE); if (hstResponse == null && pageContext.getResponse() instanceof HstResponse) { hstResponse = (HstResponse) pageContext.getResponse(); } if (hstResponse != null) { namespace = hstResponse.getNamespace(); } JspWriter writer = pageContext.getOut(); try { writer.print(namespace); } catch (IOException ioe) { throw new JspException("Unable to write namespace", ioe); } return SKIP_BODY; } }
public int doStartTag() throws JspException { String namespace = ""; // if hstResponse is retrieved, then this servlet has been dispatched by hst component. HstResponse hstResponse = (HstResponse) pageContext.getRequest().getAttribute(ContainerConstants.HST_RESPONSE); if (hstResponse == null && pageContext.getResponse() instanceof HstResponse) { hstResponse = (HstResponse) pageContext.getResponse(); } if (hstResponse != null) { namespace = hstResponse.getNamespace(); } JspWriter writer = pageContext.getOut(); try { writer.print(namespace); } catch (IOException ioe) { throw new JspException("Unable to write namespace", ioe); } return SKIP_BODY; } }
protected void setComponentId(final HstRequest request, final HstResponse response) { if (RequestContextProvider.get().isCmsRequest()) { request.setAttribute(REQUEST_ATTR_COMPONENT_ID, UUID.randomUUID().toString()); } else { request.setAttribute(REQUEST_ATTR_COMPONENT_ID, response.getNamespace()); } }
@Override public void doAction(HstRequest request, HstResponse response) throws HstComponentException { doDispatch(getDispatchPathParameter(request, request.getLifecyclePhase()), request, response); if (Boolean.parseBoolean(getParameter(SHARED_REQUEST_ATTRIBUTES_PARAM_NAME, request, null))) { String sharedAttributeNamePrefix = getParameter(SHARED_REQUEST_ATTRIBUTES_SESSION_ATTRIBUTE_NAME_PREFIX_PARAM_NAME, request, DEFAULT_SHARED_REQUEST_ATTRIBUTES_SESSION_ATTRIBUTE_NAME_PREFIX); String sharedAttributeName = sharedAttributeNamePrefix + response.getNamespace(); Map<String, Object> sharedAttrMap = new HashMap<String, Object>(); String attrName = null; Object attrValue = null; for (Enumeration attrNames = request.getAttributeNames(); attrNames.hasMoreElements(); ) { attrName = (String) attrNames.nextElement(); if (!attrName.startsWith("javax.")) { attrValue = request.getAttribute(attrName); if (attrValue != null) { sharedAttrMap.put(attrName, attrValue); } } } request.getSession(true).setAttribute(sharedAttributeName, sharedAttrMap); } }
@Override public void doAction(HstRequest request, HstResponse response) throws HstComponentException { doDispatch(getDispatchPathParameter(request, request.getLifecyclePhase()), request, response); if (Boolean.parseBoolean(getParameter(SHARED_REQUEST_ATTRIBUTES_PARAM_NAME, request, null))) { String sharedAttributeNamePrefix = getParameter(SHARED_REQUEST_ATTRIBUTES_SESSION_ATTRIBUTE_NAME_PREFIX_PARAM_NAME, request, DEFAULT_SHARED_REQUEST_ATTRIBUTES_SESSION_ATTRIBUTE_NAME_PREFIX); String sharedAttributeName = sharedAttributeNamePrefix + response.getNamespace(); Map<String, Object> sharedAttrMap = new HashMap<String, Object>(); String attrName = null; Object attrValue = null; for (Enumeration attrNames = request.getAttributeNames(); attrNames.hasMoreElements(); ) { attrName = (String) attrNames.nextElement(); if (!attrName.startsWith("javax.")) { attrValue = request.getAttribute(attrName); if (attrValue != null) { sharedAttrMap.put(attrName, attrValue); } } } request.getSession(true).setAttribute(sharedAttributeName, sharedAttrMap); } }
String sharedAttributeName = sharedAttributeNamePrefix + response.getNamespace(); Map<String, Object> sharedAttrMap = (Map<String, Object>) session.getAttribute(sharedAttributeName);
String sharedAttributeName = sharedAttributeNamePrefix + response.getNamespace(); Map<String, Object> sharedAttrMap = (Map<String, Object>) session.getAttribute(sharedAttributeName);