use of javax.servlet.jsp.PageContext in project sling by apache.
the class JspFactoryImpl method internalGetPageContext.
private PageContext internalGetPageContext(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL, boolean needsSession, int bufferSize, boolean autoflush) {
try {
PageContext pc = new PageContextImpl();
pc.initialize(servlet, request, response, errorPageURL, needsSession, bufferSize, autoflush);
return pc;
} catch (Throwable ex) {
/* FIXME: need to do something reasonable here!! */
log.fatal("Exception initializing page context", ex);
return null;
}
}
use of javax.servlet.jsp.PageContext in project opennms by OpenNMS.
the class EvaluationTest method runTests.
// -------------------------------------
/**
* Runs the tests, reading expressions from pIn and writing the
* results to pOut.
*/
public static void runTests(DataInput pIn, PrintStream pOut) throws IOException {
PageContext context = createTestContext();
while (true) {
String str = pIn.readLine();
if (str == null)
break;
if (str.startsWith("#") || "".equals(str.trim())) {
pOut.println(str);
} else {
String typeStr = pIn.readLine();
pOut.println("Expression: " + str);
try {
Class cl = parseClassName(typeStr);
pOut.println("ExpectedType: " + cl);
Evaluator e = new Evaluator();
Object val = e.evaluate("test", str, cl, null, context);
pOut.println("Evaluates to: " + val);
if (val != null) {
pOut.println("With type: " + val.getClass().getName());
}
pOut.println();
} catch (JspException exc) {
pOut.println("Causes an error: " + exc);
} catch (ClassNotFoundException exc) {
pOut.println("Causes an error: " + exc);
}
}
}
}
use of javax.servlet.jsp.PageContext in project tomcat70 by apache.
the class ImplicitObjectELResolver method getValue.
@Override
public Object getValue(ELContext context, Object base, Object property) throws NullPointerException, PropertyNotFoundException, ELException {
if (context == null) {
throw new NullPointerException();
}
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(true);
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 tomcat70 by apache.
the class ScopedAttributeELResolver method getValue.
@Override
public Object getValue(ELContext context, Object base, Object property) throws NullPointerException, PropertyNotFoundException, ELException {
if (context == null) {
throw new NullPointerException();
}
if (base == null) {
context.setPropertyResolved(true);
if (property != null) {
String key = property.toString();
PageContext page = (PageContext) context.getContext(JspContext.class);
return page.findAttribute(key);
}
}
return null;
}
use of javax.servlet.jsp.PageContext in project tomcat70 by apache.
the class ScopedAttributeELResolver method setValue.
@Override
public void setValue(ELContext context, Object base, Object property, Object value) throws NullPointerException, PropertyNotFoundException, PropertyNotWritableException, ELException {
if (context == null) {
throw new NullPointerException();
}
if (base == null) {
context.setPropertyResolved(true);
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);
}
}
}
}
Aggregations