use of javax.servlet.jsp.JspException in project logging-log4j2 by apache.
the class DumpTag method doEndTag.
@Override
public int doEndTag() throws JspException {
try {
final Enumeration<String> names = this.pageContext.getAttributeNamesInScope(this.scope);
this.pageContext.getOut().write("<dl>");
while (names != null && names.hasMoreElements()) {
final String name = names.nextElement();
final Object value = this.pageContext.getAttribute(name, this.scope);
this.pageContext.getOut().write("<dt><code>" + name + "</code></dt>");
this.pageContext.getOut().write("<dd><code>" + value + "</code></dd>");
}
this.pageContext.getOut().write("</dl>");
} catch (final IOException e) {
throw new JspException("Could not write scope contents. Cause: " + e.toString(), e);
}
return Tag.EVAL_PAGE;
}
use of javax.servlet.jsp.JspException in project sling by apache.
the class EvalTagHandler method doEndTag.
/**
* Called after the body has been processed.
*
* @return whether additional evaluations of the body are desired
*/
public int doEndTag() throws JspException {
log.debug("EvalTagHandler doEndTag");
final SlingBindings bindings = (SlingBindings) pageContext.getRequest().getAttribute(SlingBindings.class.getName());
final SlingScriptHelper scriptHelper = bindings.getSling();
final ServletResolver servletResolver = scriptHelper.getService(ServletResolver.class);
final Servlet servlet;
if (!this.ignoreResourceTypeHierarchy) {
// detecte resource
final Resource resource;
if (this.resource != null) {
resource = this.resource;
} else if (this.resourceType != null) {
resource = new SyntheticResource(bindings.getRequest().getResourceResolver(), bindings.getResource().getPath(), this.resourceType);
} else {
resource = bindings.getResource();
}
servlet = servletResolver.resolveServlet(resource, this.script);
} else {
final ResourceResolver rr = bindings.getRequest().getResourceResolver();
final String scriptPath;
if (!script.startsWith("/")) {
// resolve relative script
String parentPath = ResourceUtil.getParent(scriptHelper.getScript().getScriptResource().getPath());
// check if parent resides on search path
for (String sp : rr.getSearchPath()) {
if (parentPath.startsWith(sp)) {
parentPath = parentPath.substring(sp.length());
break;
}
}
scriptPath = parentPath + '/' + script;
} else {
scriptPath = this.script;
}
servlet = servletResolver.resolveServlet(rr, scriptPath);
}
if (servlet == null) {
throw new JspException("Could not find script '" + script + "' referenced in jsp " + scriptHelper.getScript().getScriptResource().getPath());
}
try {
if (flush && !(pageContext.getOut() instanceof BodyContent)) {
// might throw an IOException of course
pageContext.getOut().flush();
}
// wrap the response to get the correct output order
SlingHttpServletResponse response = new JspSlingHttpServletResponseWrapper(pageContext);
servlet.service(pageContext.getRequest(), response);
return EVAL_PAGE;
} catch (Exception e) {
log.error("Error while executing script " + script, e);
throw new JspException("Error while executing script " + script, e);
}
}
use of javax.servlet.jsp.JspException in project sling by apache.
the class TagHandlerPool method get.
/**
* Gets the next available tag handler from this tag handler pool,
* instantiating one if this tag handler pool is empty.
*
* @param handlerClass Tag handler class
*
* @return Reused or newly instantiated tag handler
*
* @throws JspException if a tag handler cannot be instantiated
*/
public Tag get(Class handlerClass) throws JspException {
Tag handler = null;
synchronized (this) {
if (current >= 0) {
handler = handlers[current--];
return handler;
}
}
// wait for us to construct a tag for this thread.
try {
Tag instance = (Tag) handlerClass.newInstance();
AnnotationHelper.postConstruct(annotationProcessor, instance);
return instance;
} catch (Exception e) {
throw new JspException(e.getMessage(), e);
}
}
use of javax.servlet.jsp.JspException in project bamboobsc by billchen198318.
the class ToolBarTag method doEndTag.
@Override
public int doEndTag() throws JspException {
ToolBar toolBar = this.handler();
try {
this.pageContext.getOut().write(toolBar.getHtml());
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
toolBar = null;
return 0;
}
use of javax.servlet.jsp.JspException in project bamboobsc by billchen198318.
the class InputfieldNoticeMsgLabelTag method doEndTag.
@Override
public int doEndTag() throws JspException {
InputfieldNoticeMsgLabel msgLabel = this.handler();
try {
this.pageContext.getOut().write(msgLabel.getHtml());
this.pageContext.getOut().write(msgLabel.getScript());
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
msgLabel = null;
return 0;
}
Aggregations