use of javax.servlet.jsp.PageContext in project Openfire by igniterealtime.
the class FlashMessageTag method doTag.
@Override
public void doTag() throws IOException {
final PageContext pageContext = (PageContext) getJspContext();
final JspWriter jspWriter = pageContext.getOut();
final HttpSession session = pageContext.getSession();
for (final String flash : new String[] { SUCCESS_MESSAGE_KEY, WARNING_MESSAGE_KEY, ERROR_MESSAGE_KEY }) {
final Object flashValue = session.getAttribute(flash);
if (flashValue != null) {
jspWriter.append(String.format("<div class='%s'>%s</div>", flash, flashValue));
session.setAttribute(flash, null);
}
}
}
use of javax.servlet.jsp.PageContext in project tomcat by apache.
the class ImplicitObjectELResolver method getValue.
@Override
public Object getValue(ELContext context, Object base, Object property) {
Objects.requireNonNull(context);
if (base == null && property != null) {
int idx = Arrays.binarySearch(SCOPE_NAMES, property.toString());
if (idx >= 0) {
PageContext page = (PageContext) context.getContext(JspContext.class);
context.setPropertyResolved(base, property);
switch(idx) {
case APPLICATIONSCOPE:
return ScopeManager.get(page).getApplicationScope();
case COOKIE:
return ScopeManager.get(page).getCookie();
case HEADER:
return ScopeManager.get(page).getHeader();
case HEADERVALUES:
return ScopeManager.get(page).getHeaderValues();
case INITPARAM:
return ScopeManager.get(page).getInitParam();
case PAGECONTEXT:
return ScopeManager.get(page).getPageContext();
case PAGESCOPE:
return ScopeManager.get(page).getPageScope();
case PARAM:
return ScopeManager.get(page).getParam();
case PARAM_VALUES:
return ScopeManager.get(page).getParamValues();
case REQUEST_SCOPE:
return ScopeManager.get(page).getRequestScope();
case SESSION_SCOPE:
return ScopeManager.get(page).getSessionScope();
}
}
}
return null;
}
use of javax.servlet.jsp.PageContext in project tomcat by apache.
the class ScopedAttributeELResolver method getFeatureDescriptors.
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
PageContext ctxt = (PageContext) context.getContext(JspContext.class);
List<FeatureDescriptor> list = new ArrayList<>();
Enumeration<String> e;
Object value;
String name;
e = ctxt.getAttributeNamesInScope(PageContext.PAGE_SCOPE);
while (e.hasMoreElements()) {
name = e.nextElement();
value = ctxt.getAttribute(name, PageContext.PAGE_SCOPE);
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setName(name);
descriptor.setDisplayName(name);
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setPreferred(true);
descriptor.setShortDescription("page scoped attribute");
descriptor.setValue("type", value.getClass());
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
list.add(descriptor);
}
e = ctxt.getAttributeNamesInScope(PageContext.REQUEST_SCOPE);
while (e.hasMoreElements()) {
name = e.nextElement();
value = ctxt.getAttribute(name, PageContext.REQUEST_SCOPE);
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setName(name);
descriptor.setDisplayName(name);
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setPreferred(true);
descriptor.setShortDescription("request scope attribute");
descriptor.setValue("type", value.getClass());
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
list.add(descriptor);
}
if (ctxt.getSession() != null) {
e = ctxt.getAttributeNamesInScope(PageContext.SESSION_SCOPE);
while (e.hasMoreElements()) {
name = e.nextElement();
value = ctxt.getAttribute(name, PageContext.SESSION_SCOPE);
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setName(name);
descriptor.setDisplayName(name);
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setPreferred(true);
descriptor.setShortDescription("session scoped attribute");
descriptor.setValue("type", value.getClass());
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
list.add(descriptor);
}
}
e = ctxt.getAttributeNamesInScope(PageContext.APPLICATION_SCOPE);
while (e.hasMoreElements()) {
name = e.nextElement();
value = ctxt.getAttribute(name, PageContext.APPLICATION_SCOPE);
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setName(name);
descriptor.setDisplayName(name);
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setPreferred(true);
descriptor.setShortDescription("application scoped attribute");
descriptor.setValue("type", value.getClass());
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
list.add(descriptor);
}
return list.iterator();
}
use of javax.servlet.jsp.PageContext in project jodd by oblac.
the class DebugTag method doTag.
@Override
public void doTag() throws JspException, IOException {
PageContext pageContext = (PageContext) getJspContext();
JspWriter out = getJspContext().getOut();
out.println(ServletUtil.debug(pageContext));
}
use of javax.servlet.jsp.PageContext in project spring-framework by spring-projects.
the class MessageTagTests method messageTagWithNullCode.
@Test
public void messageTagWithNullCode() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
MessageTag tag = new MessageTag() {
@Override
protected void writeMessage(String msg) {
message.append(msg);
}
};
tag.setPageContext(pc);
tag.setCode(null);
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
assertEquals("Correct doEndTag return value", Tag.EVAL_PAGE, tag.doEndTag());
assertEquals("Correct message", "null", message.toString());
}
Aggregations