Search in sources :

Example 71 with JspException

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;
}
Also used : JspException(javax.servlet.jsp.JspException) IOException(java.io.IOException)

Example 72 with JspException

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);
    }
}
Also used : SlingHttpServletResponse(org.apache.sling.api.SlingHttpServletResponse) JspSlingHttpServletResponseWrapper(org.apache.sling.scripting.jsp.util.JspSlingHttpServletResponseWrapper) SlingBindings(org.apache.sling.api.scripting.SlingBindings) SlingScriptHelper(org.apache.sling.api.scripting.SlingScriptHelper) Resource(org.apache.sling.api.resource.Resource) SyntheticResource(org.apache.sling.api.resource.SyntheticResource) SyntheticResource(org.apache.sling.api.resource.SyntheticResource) JspException(javax.servlet.jsp.JspException) BodyContent(javax.servlet.jsp.tagext.BodyContent) JspException(javax.servlet.jsp.JspException) ServletResolver(org.apache.sling.api.servlets.ServletResolver) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) Servlet(javax.servlet.Servlet)

Example 73 with JspException

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);
    }
}
Also used : JspException(javax.servlet.jsp.JspException) Tag(javax.servlet.jsp.tagext.Tag) JspException(javax.servlet.jsp.JspException)

Example 74 with JspException

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;
}
Also used : ToolBar(org.gsweb.components.ui.ToolBar) IOException(java.io.IOException) JspException(javax.servlet.jsp.JspException) IOException(java.io.IOException)

Example 75 with JspException

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;
}
Also used : InputfieldNoticeMsgLabel(org.gsweb.components.ui.InputfieldNoticeMsgLabel) IOException(java.io.IOException) JspException(javax.servlet.jsp.JspException) IOException(java.io.IOException)

Aggregations

JspException (javax.servlet.jsp.JspException)158 IOException (java.io.IOException)34 Map (java.util.Map)30 HashMap (java.util.HashMap)21 HttpServletRequest (javax.servlet.http.HttpServletRequest)21 JspWriter (javax.servlet.jsp.JspWriter)21 Iterator (java.util.Iterator)20 ActionMessages (org.apache.struts.action.ActionMessages)15 MockFormBean (org.apache.struts.mock.MockFormBean)15 InvocationTargetException (java.lang.reflect.InvocationTargetException)11 ActionMessage (org.apache.struts.action.ActionMessage)11 ArrayList (java.util.ArrayList)7 Collection (java.util.Collection)7 List (java.util.List)7 Locale (java.util.Locale)6 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)6 MalformedURLException (java.net.MalformedURLException)5 ModuleConfig (org.apache.struts.config.ModuleConfig)5 UserContext (org.mifos.security.util.UserContext)5 SimpleDateFormat (java.text.SimpleDateFormat)4