use of jakarta.servlet.jsp.PageContext in project tomcat by apache.
the class ScopedAttributeELResolver method getValue.
@Override
public Object getValue(ELContext context, Object base, Object property) {
Objects.requireNonNull(context);
Object result = null;
if (base == null) {
if (property != null) {
String key = property.toString();
PageContext page = (PageContext) context.getContext(JspContext.class);
result = page.findAttribute(key);
if (result != null) {
context.setPropertyResolved(base, property);
}
}
}
return result;
}
use of jakarta.servlet.jsp.PageContext in project tomcat by apache.
the class ScopedAttributeELResolver method getFeatureDescriptors.
@Deprecated(forRemoval = true, since = "JSP 3.1")
@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 jakarta.servlet.jsp.PageContext in project tomcat by apache.
the class ScopedAttributeELResolver method setValue.
@Override
public void setValue(ELContext context, Object base, Object property, Object value) {
Objects.requireNonNull(context);
if (base == null) {
context.setPropertyResolved(base, property);
if (property != null) {
String key = property.toString();
PageContext page = (PageContext) context.getContext(JspContext.class);
int scope = page.getAttributesScope(key);
if (scope != 0) {
page.setAttribute(key, value, scope);
} else {
page.setAttribute(key, value);
}
}
}
}
use of jakarta.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 jakarta.servlet.jsp.PageContext in project spring-framework by spring-projects.
the class ArgumentTagTests method setUp.
@BeforeEach
public void setUp() throws Exception {
PageContext context = createPageContext();
parent = new MockArgumentSupportTag();
tag = new ArgumentTag();
tag.setPageContext(context);
tag.setParent(parent);
}
Aggregations