Example usage for javax.servlet.jsp JspException JspException

List of usage examples for javax.servlet.jsp JspException JspException

Introduction

In this page you can find the example usage for javax.servlet.jsp JspException JspException.

Prototype

public JspException(Throwable cause) 

Source Link

Document

Constructs a new JspException with the specified cause.

Usage

From source file:org.alfresco.web.awe.tag.MarkContentTag.java

/**
 * @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
 *//*from  w w w  .j  a v  a 2  s  . c  om*/
public int doStartTag() throws JspException {
    if (isEditingEnabled()) {
        try {
            Writer out = pageContext.getOut();

            // get the prefix URL to the AWE assets
            String urlPrefix = getWebEditorUrlPrefix();

            // generate a unique id for this marked content
            List<MarkedContent> markedContent = AlfrescoTagUtil.getMarkedContent(pageContext.getRequest());
            String markerIdPrefix = (String) this.pageContext.getRequest()
                    .getAttribute(AlfrescoTagUtil.KEY_MARKER_ID_PREFIX);

            String redirectUrl = AlfrescoTagUtil
                    .calculateRedirectUrl((HttpServletRequest) pageContext.getRequest());
            String editMarkerId = markerIdPrefix + "-" + (markedContent.size() + 1);

            // create marked content object and store
            MarkedContent content = new MarkedContent(editMarkerId, this.contentId, this.contentTitle,
                    this.formId, this.nestedMarker);
            markedContent.add(content);

            AlfrescoTagUtil.writeMarkContentHtml(out, urlPrefix, redirectUrl, content);

            if (logger.isDebugEnabled()) {
                logger.debug("Completed markContent rendering for: " + content);
            }
        } catch (IOException ioe) {
            throw new JspException(ioe.toString());
        }
    } else if (logger.isDebugEnabled()) {
        logger.debug("Skipping markContent rendering as editing is disabled");
    }

    return SKIP_BODY;
}

From source file:org.alfresco.web.ui.repo.tag.PageTag.java

/**
 * @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
 *///w w w.  j  a v a 2  s  .  co  m
public int doStartTag() throws JspException {
    if (logger.isDebugEnabled())
        startTime = System.currentTimeMillis();

    try {
        String reqPath = ((HttpServletRequest) pageContext.getRequest()).getContextPath();
        Writer out = pageContext.getOut();

        if (!Application.inPortalServer()) {
            if (this.getDoctypeRootElement() != null && this.getDoctypePublic() != null) {
                out.write("<!DOCTYPE ");
                out.write(this.getDoctypeRootElement().toLowerCase());
                out.write(" PUBLIC \"" + this.getDoctypePublic() + "\"");
                if (this.getDoctypeSystem() != null) {
                    out.write(" \"" + this.getDoctypeSystem() + "\"");
                }
                out.write(">\n");
            } else {
                out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n");
                out.write("    \"http://www.w3.org/TR/html4/loose.dtd\">\n");
            }
            out.write("<html><head>");
            out.write("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=EmulateIE7\" />\n");
            out.write("<title>");
            if (this.titleId != null && this.titleId.length() != 0) {
                out.write(Utils.encode(Application.getMessage(pageContext.getSession(), this.titleId)));
            } else if (this.title != null && this.title.length() != 0) {
                out.write(Utils.encode(this.title));
            } else {
                out.write("Alfresco Web Client");
            }
            out.write("</title>\n");
            out.write("<link rel=\"search\" type=\"application/opensearchdescription+xml\" href=\"" + reqPath
                    + "/wcservice/api/search/keyword/description.xml\" title=\"Alfresco Keyword Search\">\n");
            out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n");
        }

        // CSS style includes
        for (final String css : PageTag.CSS) {
            out.write(STYLES_START);
            out.write(reqPath);
            out.write(css);
            out.write(STYLES_MAIN);
        }

        // JavaScript includes
        for (final String s : PageTag.SCRIPTS) {
            out.write(SCRIPTS_START);
            out.write(reqPath);
            out.write(s);
            out.write(SCRIPTS_END);
        }

        out.write("<script type=\"text/javascript\">"); // start - generate naked javascript code

        out.write("setContextPath('");
        out.write(reqPath);
        out.write("');");

        // generate window onload code
        generateWindowOnloadCode(out);

        out.write("</script>\n"); // end - generate naked javascript code

        if (!Application.inPortalServer()) {
            out.write("</head>");
            out.write("<body>\n");
        }
    } catch (IOException ioe) {
        throw new JspException(ioe.toString());
    }

    return EVAL_BODY_INCLUDE;
}

From source file:org.alfresco.web.ui.repo.tag.PageTag.java

/**
 * @see javax.servlet.jsp.tagext.TagSupport#doEndTag()
 *//*from ww w.j  a va2s  .c om*/
public int doEndTag() throws JspException {
    try {
        HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
        if (req.getRequestURI().endsWith(getLoginPage()) == false) {
            pageContext.getOut().write(getAlfrescoButton());
        }

        if (!Application.inPortalServer()) {
            pageContext.getOut().write("\n</body></html>");
        }
    } catch (IOException ioe) {
        throw new JspException(ioe.toString());
    }

    if (logger.isDebugEnabled()) {
        long endTime = System.currentTimeMillis();
        logger.debug("Time to generate page: " + (endTime - startTime) + "ms");
    }

    return super.doEndTag();
}

From source file:org.alfresco.web.ui.repo.tag.UploadFormTag.java

/**
 * @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
 *///  w  ww .j av  a2 s  .c  om
public int doStartTag() throws JspException {
    try {
        Writer out = pageContext.getOut();

        out.write(
                "<form name='upload-form' acceptCharset='UTF-8' method='post' enctype='multipart/form-data' action='");

        if (Application.inPortalServer()) {
            out.write(AlfrescoFacesPortlet.getActionURL(pageContext.getRequest()));
            out.write("'>");
        } else {
            HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
            out.write(req.getContextPath());
            out.write("/uploadFileServlet'>\n");
            out.write("<input type='hidden' name='return-page' value='");
            out.write(req.getContextPath() + BaseServlet.FACES_SERVLET + req.getServletPath());
            out.write("'>\n");
        }
    } catch (IOException ioe) {
        throw new JspException(ioe.toString());
    }

    return EVAL_BODY_INCLUDE;
}

From source file:org.alfresco.web.ui.repo.tag.UploadFormTag.java

public int doEndTag() throws JspException {
    try {//w w w  .  j  av a  2 s.c  o m
        pageContext.getOut().write("\n</form>");
    } catch (IOException ioe) {
        throw new JspException(ioe.toString());
    }

    return super.doEndTag();
}

From source file:org.anyframe.iam.core.taglibs.ViewResourceTag.java

/**
 * As initialize logic of tag, get Spring context to use viewResourceAccessService bean.
 * //from   w w w.  jav a 2s  . c o  m
 * @throws JspException
 */
protected void initializeIfRequired() throws JspException {
    if (context != null) {
        return;
    }

    Map beanMap = getContext().getBeansOfType(IViewResourceAccessService.class);
    if (beanMap.size() > 0) {
        viewResourceAccessService = (IViewResourceAccessService) beanMap.values().iterator().next();
    } else {
        throw new JspException("viewResourceAccessService bean was not found in application context");
    }
}

From source file:org.apache.cactus.extension.jsp.JspTagLifecycle.java

/**
 * Invokes the tag with the provided interceptor. The tag should have been
 * populated with its properties before calling this method. The tag is not
 * released after the tag's lifecycle is over.
 * /* ww w  .j a v  a2  s  .  c  o  m*/
 * @throws JspException If the tag throws an exception
 * @throws IOException If an error occurs when reading or writing the body
 *         content
 */
public void invoke() throws JspException, IOException {
    if (this.tag instanceof TryCatchFinally) {
        TryCatchFinally tryCatchFinally = (TryCatchFinally) this.tag;
        try {
            invokeInternal();
        } catch (Throwable t1) {
            try {
                tryCatchFinally.doCatch(t1);
            } catch (Throwable t2) {
                throw new JspException(t2.getMessage());
            }
        } finally {
            tryCatchFinally.doFinally();
        }
    } else {
        invokeInternal();
    }
}

From source file:org.apache.myfaces.custom.valueChangeNotifier.ValueChangeNotifierTag.java

public int doStartTag() throws JspException {
    if (method == null) {
        throw new JspException("name attribute not set");
    }//from  ww  w. java  2  s .c  o m

    // Find parent UIComponentTag
    UIComponentTag componentTag = UIComponentTag.getParentUIComponentTag(pageContext);
    if (componentTag == null) {
        throw new JspException("ValueChangeListenerTag has no UIComponentTag ancestor");
    }

    if (componentTag.getCreated()) {
        // Component was just created, so we add the Listener
        UIComponent component = componentTag.getComponentInstance();
        if (component instanceof EditableValueHolder) {
            setupClassListener(component);
        } else {
            throw new JspException("Component " + component.getId() + " is no EditableValueHolder");
        }
    }

    return Tag.SKIP_BODY;
}

From source file:org.apache.myfaces.taglib.core.LoadBundleTag.java

public int doStartTag() throws JspException {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    if (facesContext == null) {
        throw new JspException("No faces context?!");
    }//  www  .j a v  a 2s  .  com

    try {
        resolveBundle(getBasename(facesContext));
    } catch (IllegalStateException ex) {
        throw new JspException(ex);
    }

    return Tag.SKIP_BODY;
}

From source file:org.apache.myfaces.taglib.core.ViewTag.java

public int doStartTag() throws JspException {
    if (log.isTraceEnabled())
        log.trace("entering ViewTag.doStartTag");
    super.doStartTag();
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ResponseWriter responseWriter = facesContext.getResponseWriter();
    try {// w ww  .  j  a va  2 s.com
        responseWriter.startDocument();
    } catch (IOException e) {
        log.error("Error writing startDocument", e);
        throw new JspException(e);
    }

    if (log.isTraceEnabled())
        log.trace("leaving ViewTag.doStartTag");
    return BodyTag.EVAL_BODY_BUFFERED;
}