List of usage examples for org.apache.commons.jxpath.servlet JXPathServletContexts getRequestContext
public static JXPathContext getRequestContext(ServletRequest request, ServletContext servletContext)
From source file:com.netspective.sparx.console.form.InspectObject.java
public void execute(Writer writer, DialogContext dc) throws IOException, DialogExecuteException { JXPathContext jxPathContext = null;/*from w w w .j a v a2s . com*/ DialogFieldStates fieldStates = dc.getFieldStates(); String contextValue = fieldStates.getState("context").getValue().getTextValue(); String jxPathExprValue = fieldStates.getState("jxpath-expr").getValue().getTextValue(); String action = fieldStates.getState("action").getValue().getTextValue(); if (contextValue.equalsIgnoreCase("Project")) jxPathContext = JXPathContext.newContext(dc.getProject()); else if (contextValue.equalsIgnoreCase("Servlet")) jxPathContext = JXPathContext.newContext(dc.getServlet()); else if (contextValue.equalsIgnoreCase("Application")) jxPathContext = JXPathServletContexts .getApplicationContext(dc.getServlet().getServletConfig().getServletContext()); else if (contextValue.equalsIgnoreCase("Request")) jxPathContext = JXPathServletContexts.getRequestContext(dc.getRequest(), dc.getServlet().getServletConfig().getServletContext()); else if (contextValue.equalsIgnoreCase("Session")) jxPathContext = JXPathServletContexts.getSessionContext(dc.getHttpRequest().getSession(), dc.getServlet().getServletConfig().getServletContext()); Object jxPathValue = null; if (action.equalsIgnoreCase("getValue")) jxPathValue = jxPathContext.getValue(jxPathExprValue); else jxPathValue = jxPathContext.iterate(jxPathExprValue); if (jxPathValue != null) { Map vars = new HashMap(); vars.put("jxPathValue", jxPathValue); vars.put("jxPathExpr", jxPathExprValue); inspectJxPathValueTemplate.process(writer, dc, vars); } else writer.write("JXPath expression '" + jxPathExprValue + "' evaluated to NULL."); }