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:edu.cornell.mannlib.vedit.tags.ErrorTag.java

public int doEndTag() throws JspException {
    try {/*  w w  w  .  j  ava 2  s .  c o  m*/
        JspWriter out = pageContext.getOut();

        String errors = null;
        try {
            errors = (String) getFormObject().getErrorMap().get(name);
        } catch (Exception e) {
            System.out.println("Could not get the form object from which to extract validation error message.");
        }

        if (errors != null) {
            out.print(StringEscapeUtils.escapeHtml((String) errors));
        }

    } catch (Exception ex) {
        throw new JspException(ex.getMessage());
    }
    return SKIP_BODY;
}

From source file:com.googlecode.psiprobe.jsp.DurationTag.java

public int doStartTag() throws JspException {
    try {/*from   w  ww  .j  a  v a 2  s  .  com*/
        pageContext.getOut().write(duration(value));
    } catch (IOException e) {
        logger.debug("Exception writing duration to JspWriter", e);
        throw new JspException(e);
    }
    return EVAL_BODY_INCLUDE;
}

From source file:gov.nih.nci.calims2.taglib.EnumTag.java

/**
 * {@inheritDoc}/*from w  w w . j a v  a  2  s. c o m*/
 */
public int doStartTag() throws JspException {
    try {
        Locale locale = TagHelper.getRequestContext(pageContext).getLocale();
        if (value != null) {
            String message = (propertyName == null) ? value.getLocalizedValue(locale)
                    : getPropertyValue(locale);
            pageContext.getOut().print(StringEscapeUtils.escapeHtml(message));
        }
        return SKIP_BODY;
    } catch (IOException e) {
        throw new JspException(e);
    } catch (Exception e) {
        throw new JspTagException(e);
    }
}

From source file:de.highbyte_le.weberknecht.request.taglibs.SiteBaseLinkTag.java

protected String getBaseUrl() throws JspException {

    if (!(pageContext.getRequest() instanceof HttpServletRequest))
        throw new JspException("unable to get a HttpServletRequest");

    StringBuilder baseUrl = new StringBuilder();

    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    try {//from  ww w . ja v a  2 s . co m
        ContextConfig conf = new ContextConfig();
        baseUrl.append(conf.getValue("webapp_base_url"));

        if (baseUrl.charAt(baseUrl.length() - 1) != '/')
            baseUrl.append("/");
    } catch (NamingException e) {
        logger.error("getTokenUrl() - naming exception while fetching webapp_base_url: " + e.getMessage()); //$NON-NLS-1$

        logger.warn("automatically generating base URL");
        String contextPath = request.getContextPath();
        String localHost = request.getLocalName();
        int localPort = request.getLocalPort();

        if (baseUrl.length() > 0) //just to be sure
            baseUrl = new StringBuilder();

        baseUrl.append("http://").append(localHost).append(":").append(localPort + contextPath).append("/");
    }

    return baseUrl.toString();
}

From source file:gov.nih.nci.cabig.ctms.acegi.csm.web.CSMAccessControlTag.java

public int doStartTag() throws JspException {
    if (authorizationCheckName == null || authorizationCheckName.trim().length() == 0) {
        throw new JspException("authorizationCheckName is required");
    }//w  ww . j  a v a  2  s. c o  m

    String evaledAuthorizationCheckName = ExpressionEvaluationUtils.evaluateString("authorizationCheckName",
            authorizationCheckName, pageContext);

    String evaledPrivilegesString = hasPrivileges;
    if (evaledPrivilegesString != null && evaledPrivilegesString.trim().length() > 0) {
        evaledPrivilegesString = ExpressionEvaluationUtils.evaluateString("hasPrivileges", hasPrivileges,
                pageContext);
    }

    String[] requiredPrivileges = evaledPrivilegesString.split(",");

    Object resolvedDomainObject = null;

    if (domainObject instanceof String) {
        resolvedDomainObject = ExpressionEvaluationUtils.evaluate("domainObject", (String) domainObject,
                Object.class, pageContext);
    } else {
        resolvedDomainObject = domainObject;
    }

    if (resolvedDomainObject == null) {

        logger.debug("domainObject resolved to null, so including tag body");

        return Tag.EVAL_BODY_INCLUDE;
    }

    Authentication auth = getAuthentication();

    ApplicationContext context = getContext(pageContext);

    CSMAuthorizationCheck authzCheck = (CSMAuthorizationCheck) context.getBean(evaledAuthorizationCheckName);
    if (authzCheck == null) {
        throw new JspException(
                "No authorization check found for bean name '" + evaledAuthorizationCheckName + "'.");
    }

    for (String requiredPrivilege : requiredPrivileges) {

        if (authzCheck.checkAuthorization(auth, requiredPrivilege, resolvedDomainObject)) {
            logger.debug("Authorization succeeded, evaluating body");
            return Tag.EVAL_BODY_INCLUDE;
        }

    }

    logger.debug("No permission, so skipping tag body");

    return Tag.SKIP_BODY;
}

From source file:edu.cornell.mannlib.vedit.tags.ValueTag.java

public int doEndTag() throws JspException {
    try {/*from   w w w  .  j av a 2 s  .c  o m*/
        JspWriter out = pageContext.getOut();

        HashMap values = null;
        try {
            // FormObject foo = (FormObject) pageContext.getSession().getAttribute("FormObject");
            // FormObject foo = TagUtils.getFormObject(pageContext);
            FormObject foo = getFormObject();
            values = foo.getValues();
        } catch (Exception e) {
            System.out.println("Could not get the form object from which to build an option list");
        }

        if (values != null) {
            String value = (String) values.get(name);
            if (value != null)
                out.print(StringEscapeUtils.escapeHtml(value));
        } else {
            System.out.println("ValueTag unable to get HashMap of form values");
        }

    } catch (Exception ex) {
        throw new JspException(ex.getMessage());
    }
    return SKIP_BODY;
}

From source file:cn.vlabs.umt.ui.tags.SsoParamsTag.java

public int doEndTag() throws JspException {
    ServletRequest request = pageContext.getRequest();
    JspWriter writer = pageContext.getOut();
    for (String param : Attributes.SSO_PARAMS) {
        String value = request.getParameter(param);
        if (StringUtils.isNotBlank(value)) {
            try {
                writer.println(String.format("<input type=\"hidden\" name=\"%s\" value=\"%s\">", param, value));
            } catch (IOException e) {
                throw new JspException(e);
            }//w w w  .j  a v a 2  s  . c om
        }
    }
    return EVAL_PAGE;
}

From source file:com.bstek.dorado.view.taglib.PageFooterTag.java

@Override
public int doEndTag() throws JspException {
    try {/*from ww  w . j ava2 s.  c  o m*/
        View view = PageOutputUtils.getView((HttpServletRequest) pageContext.getRequest());
        PageOutputUtils.outputFooter(view, (HttpServletRequest) pageContext.getRequest(),
                (HttpServletResponse) pageContext.getResponse(), pageContext.getOut());
    } catch (Exception e) {
        logger.error(e, e);
        throw new JspException(e);
    }
    return super.doEndTag();
}

From source file:com.bstek.dorado.view.taglib.PageHeaderTag.java

@Override
public int doEndTag() throws JspException {
    try {/*from   w w  w.  j a  v  a 2  s  .  c om*/
        View view = PageOutputUtils.getView((HttpServletRequest) pageContext.getRequest());
        PageOutputUtils.outputHeader(view, (HttpServletRequest) pageContext.getRequest(),
                (HttpServletResponse) pageContext.getResponse(), pageContext.getOut());
    } catch (Exception e) {
        logger.error(e, e);
        throw new JspException(e);
    }
    return super.doEndTag();
}

From source file:cn.vlabs.umt.ui.tags.RequestCount.java

public int doStartTag() throws JspException {
    BeanFactory factory = (BeanFactory) pageContext.getServletContext()
            .getAttribute(Attributes.APPLICATION_CONTEXT_KEY);
    RequestService us = (RequestService) factory.getBean("RequestService");
    int count = us.getRequestCount(UserRequest.INIT);
    try {//from w  w  w .j av a 2s  .com
        Writer writer = pageContext.getOut();
        writer.write(Integer.toString(count));
        writer.flush();
    } catch (IOException e) {
        throw new JspException(e);
    }
    return SKIP_BODY;
}